This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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