hibernate

SINGLE_TABLE inheritance strategy using enums as discriminator value

Is it possible to use an enum as a discriminator value when using SINGLE_TABLE inheritance strategy? ...

Is there a nice GUI available for showing Hibernate statistics?

Hibernate exposes many internal metrics via the Statistics API. Is there an easy-to-use GUI that I can use to visualize these statistics? Bonus if there is a Grails plug-in for this. ...

Getting related object's ID without fetching it from the database (Play framework)

Say I have these two models: public class City extends Model { @ManyToOne private Country country; } public class Country extends Model { } I have a City object and want to know the related Country's ID. I could fetch from the database by doing city.getCountry().getId() but that seems very wasteful. How can I just get the ID ...

Detach JPA objects with lazy initialized properties

There are two JPA entities: User and Order with one-to-many relationship. /** * User DTO */ @Entity @Table(name="user") public class User implements Serializable { private static final long serialVersionUID = 8372128484215085291L; private Long id; private Set<Order> orders; public User() {} @Id @GeneratedValue(s...

Hibernate Criteria - Exclude groupProperty from select

I would like to use a hibernate criteria object as a subquery on a second criteria, like this: DetachedCriteria latestStatusSubquery = DetachedCriteria.forClass(BatchStatus.class); latestStatusSubquery.setProjection(Projections.projectionList() .add( Projections.max("created"), "latestStatusDate") .add( P...

How to query by page from to table by Hibernate?

I create 3 tables by Hibernate, how to return a List<task> when set task_status = ? and set create_user_id = ?, task_status in "dotask" table, create_user_id in task table. How to write the "HQL"? Here is mine, but I can't make it true with it: String hql="from task t left join dotask d on d.task_status = ? and t.create_user_id = ? li...

Hibernate Mapping: Class having more than one possible value from an enum

I am doing a simple web page and I have a NurseForm entity. When the nurse sees a patient he/she fills this form. One of this form field is "Actions done" which is basically an enum with: public enum NurseAction { GIVE_MEDICINE, PERFORM_SUTURE, SPRAY_THERAPY, NEBULIZATIONS; } A nurse can perform more than one action so I have a p...

Can someone point me to a particularly good resource on JPA/Hibernate lazy/eager fetching?

Looking for a really good article that includes strategies/bugs/workarounds. I would prefer a pure JPA solution but I know Hibernate offers a lot of extensions. ...

JPA/Hibernate with optimistic locking and EHCache. Dirty checking interceptor not working properly.

Hi, folks. I am working on a JPA setup with optimistic locking (@Version) and EHCache. The underlying provider is Hibernate. I hooked a HibernateDirtyCheckInterceptor (extends EmptyInterceptor) into the Spring config file. This part is working, as my log entries get posted. My entity class clearly defines itself as not dirty, and the fi...

Clearing Entire Database (for unit testing with Hibernate)

My unit tests use Hibernate to connect to an in-memory HSQLDB database. I was hoping there would be a way to clear and recreate the database (the entire database including the schema and all the data) in JUnit's TestCase.setUp() method. ...

When to go for Caching/Second level cache? Any practical scenario with specifics?

I'm working on a web based application that belongs to an automobil manufacturer, developed in Spring-Hibernate with MS SQL Server 2005 database. Through this application, end users can request for creating a Car, Bus, Truck etc through web based interfaces. When a user logs in, a HTML form gets displayed for capturing technical specif...

Is HibernateCallback best for executing SQL/procedures?

I'm working on a web based application that belongs to an automobil manufacturer, developed in Spring-Hibernate with MS SQL Server 2005 database. There are three kind of use cases: 1) Through this application, end users can request for creating a Car, Bus, Truck etc through web based interfaces. When a user logs in, a HTML form gets d...

How to mapping primary key is VARCHAR2 type and excute my method to generate it.

Hi all, I'm grails newbie.i want to mapping primary key with VARCHAR2 and generate primary key using my method to generated its.how to solve this problem? ...

Can I create my own sequence in Hibernate?

Can I create my own sequence in Hibernate, like I have a database sequence and I have to add 2 characters before the sequence? ...

how to get Reusable Hibernate Criteria.?

Hi, How to clone criteria object? I have created Criteria object for joining multiple tables and applying multiple restrictions. Then i need total number of records based on the restrictions applied.Then i need to apply pagination details(by set maxList) and have to retrive List of Objects. Criteria criteria = session.createCrite...

archetype hibernate 3

i search a maven archetype for hibernate 3 (Struts 2 application) ...

Hibernate - How to map a new class to two existing Tables

I have two entities: Vehicle and Weapon classes. They are mapped respectively to Vehicle.hbm.xml and Weapon.hbm.xml. Both have their respective DAOs. All are working fine. Here's my idea. I want to create a class VehicleWeapon that has all the properties of the Vehicle and Weapon entities. I want to declare a Hibernate mapping file: Ve...

Hibernate : Foreign key has the wrong number of column. should be 0

Hi , I am trying to evaluate a mapping in this Hibernate document : section 2.2.3.1. Generating the identifier property http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-identifier In the document , Person and MedicalHistory has @OneToOne mapping (MedicalHistory points to Person) , and the do...

Prevent ehcache trying to access internet on startup

I have a fairly simple non-clustered application running ehcache with spring and hibernate. On startup I'm getting this error: <06-Sep-2010 19:14:05 o'clock BST> <Error> <Net> <Failed to communicate with proxy: 10.x.x.x/8080. Will try connection www.terracotta.org/80 now. java.net.SocketTimeoutException: connect timed out How do ...

Hibernate date conversion

I have a wierd hibernate related issue while setting a date field in an entity. The date is interpreted as UTC in the java program (i did a System.out to make sure the date assigned is in 'UTC'. However, when hibernate actually persists to the database, the date is converted to local time and stored) ex. the value has been set in the ent...