aspose file tools*
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
Author

Hibernate: not getting the associated List retrieved

Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
Hi

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.

ServiceProvider.java


BusinessLocation.java



State.java



Could someone help me out here?

Thanks


Skip Skipping
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate: not getting the associated List retrieved
 
Similar Threads
AbstractWizardFormController: teasing command object
Why isn't query ordering?
AbstractWizardFormController: java.lang.NullPointerException at processFinish(...)
java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
composite key and Criteria API [Hibernate]