hibernate

JPA mapping interfaces

Hello All I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface. I have an interface le...

Hibernate JPA to DDL command line tools

There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes. Does anyone know an easy way to do this? (Not using Ant or Maven workarounds) ...

Audit Schema Mapping with Hibernate and AOP

Hi, I am trying to audit the action that the user performed that resulted in changes to corresponding tables. For example if a user were to transfer money between 2 accounts this would generate the following sequence of events: Insert transfer amount into Transfer table Subtract transfer amount from balance in Balance Table for Accoun...

What's the Hi/Lo algorithm?

What's the Hi/Lo algorithm? I've found this in the NHibernate documentation (it's one method to generate unique keys, section 5.1.4.2), but I haven't found any good explanation of how does it work. I know that Nhibernate handles it, and I don't need to know the inside, but I'm just curious. ...

Persisting using hibernate/JPA

I have been working with hibernate/JPA on JBoss for some months now and have one question that I can't find an answer or solution for. It seems like when creating new entity beans I'm not able to do a query before I at least have called EntityManager.persist(entityBean), or else I get the following error: TransientObjectException: obje...

Rich interaction in Java/JSP web app

I'm writing a website in JSP using Struts and Hibernate. I'm looking for a way to implement a rich UI where you can have more than just buttons. For examples, drag and drops, drop down lists that updates itself in real time as you type more letters out etc. Is there a way to use something like Swing with Struts and Hibernate? Or are ther...

How to work around a potential performance issue when using a Grails hasMany relation?

Given the following domain classes: class Post { SortedSet tags static hasMany = [tags:Tag] } class Tag { static belongsTo = Post static hasMany = [posts:Post] } From my understanding so far, using a hasMany will result in hibernate SET mapping. However, in order to maintain uniqueness/order, Hibernate needs to load t...

Java Application Server Performance

I've got a somewhat dated Java EE application running on Sun Application Server 8.1 (aka SJSAS, precursor to Glassfish). With 500+ simultaneous users the application becomes unacceptably slow and I'm trying to assist in identifying where most of the execution time is spent and what can be done to speed it up. So far, we've been experim...

Java Not Converting String to Long Object Properly

We're using Spring/Hibernate on a Websphere Application Server for AIX. On my Windows machine, the problem doesn't occur--only when running off AIX. When a user logs in with an account number, if they prefix the '0' to their login ID, the application rejects the login. In the DB2 table, the column is of numeric type, and there shouldn...

How to assign Date parameters to Hibernate query for current timezone?

When you assign a date to a named SQL parameter Hibernate automatically converts it to GMT time. How do you make it use the current server timezone for all dates? Lets say you have a query: Query q = session.createQuery("from Table where date_field < :now"); q.setDate("now", new java.util.Date()); "now" will be set to GMT time, while...

Hibernate: Avoiding reading all the records to memory at once

I have a large amount of rows in the database from which I need to create an XML document. I am using hibernate 3. The basic list() method in Criteria and Query interfaces looks dangerous: I quess it pretty much has to read all the records into memory even if I only iterate over them. Or is there some lazy loading magic? If not, I seem t...

Configure Hibernate to escape underscores in LIKE clause using SQL Server dialect

I have a SQL SELECT query which has a LIKE clause containing an underscore, which should specifically look for an underscore, not treat it as a wildcard: SELECT * FROM my_table WHERE name LIKE '_H9%'; I understand that I can change the actual clause to '[_]H9%' for this to work as I expect, but the problem is that this clause is bein...

Light weight alternative to Hibernate?

I have a single user java program that I would like to have store data in a light weight database such as Derby or Sqlite. I would like to use a data abstraction layer in my program. Hibernate appears to require a lot of configuration and is overkill for what I need. What are light weight alternatives to Hibernate? ...

Auto generate data schema from JPA annotated entity classes

I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational database (MySQL or SQL Server). Is there an easy way to auto generate the database schema (table creation scripts) from the annotated classes? I'm still in the prototyping phase and anticipate frequent schema changes. I would like to be able...

How to handle: Communication link failure

Hello, We're using Spring 2.5.4/Hibernate 3.2/Websphere Application Server 6.1.0.17. We've deployed the application on an AIX box. The next day when I come in, I try to log into the application. I get this exception on the page: Error 500: Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailu...

How to get distinct results in hibernate with joins and row-based limiting (paging)?

I'm trying to implement paging using row-based limiting (for example: setFirstResult(5) and setMaxResults(10)) on a Hibernate Criteria query that has joins to other tables. Understandably, data is getting cut off randomly; and the reason for that is explained here. As a solution, the page suggests using a "second sql select" instead of...

Hibernate-like framework for C++

I am looking for database-caching framework for C++ providing the following: Generate object/table representations via some pseudo-language (macros/templates) Retrieve objects from DB by key when needed LRU caching Immediate and delayed update of DB on object update (via getter/setter methods) ...

JPA/Hibernate in Java SE 6, Best Practices for data access

I am starting a normal Java SE project and i am planning to use JPA/Hibernate. I was wondering if anyone could enlighten me as to what is considered the best way to interact with Hibernate in this environment (data access layers)? ...

Hibernate Annotation Placement Question

Hi -- I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example.... @Entity @Table(name="widget") public class Widget { private Integer id; @Id @GeneratedValue(strategy=GenerationType.AUTO) public Integer getId() { retu...

JPA CascadeType.ALL does not delete orphans.

I am having trouble deleting orphan nodes using JPA with the following mapping @OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private List<Bikes> bikes; I am having the issue of the orphaned roles hanging around the database. I can use the @org.hibernate.annotations.Cascade Hibernate specific tag ...