wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hibernate: not getting the associated List retrieved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: not getting the associated List retrieved" Watch "Hibernate: not getting the associated List retrieved" New topic

Hibernate: not getting the associated List retrieved

Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44

An entity X has a list of entity Y and the entity Y has an instance of entity Z.

The relation between X to Y is OneToMany and the relation between Y to Z is ManyToOne.

I want to retrieve X and have all the associated entities retrieved with them as well.

What HQL query do I write so that I get the whole chain retrieved all at once.
or What annonations do I use for it? At present its hibernateTemplate.find("from X").

X=ServiceProvider, Y=BusinessLocations.java, Z=State.java

I have the entities annotated below and I am having the whole chain persisted into database but when i try to retrieve the list of Y(BusinessLocation), I get nothing.

What do I do join X with Y and Y with Z?

Below are the entities x, Y and Z.




Could someone help me out here?


Skip Skipping
I agree. Here's the link: http://aspose.com/file-tools
subject: Hibernate: not getting the associated List retrieved
Similar Threads
AbstractWizardFormController: teasing command object
java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
Why isn't query ordering?
AbstractWizardFormController: java.lang.NullPointerException at processFinish(...)
composite key and Criteria API [Hibernate]