wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes How to write HQL to retrive Child object(From list) on the basis of Parent? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to write HQL to retrive Child object(From list) on the basis of Parent?" Watch "How to write HQL to retrive Child object(From list) on the basis of Parent?" New topic
Author

How to write HQL to retrive Child object(From list) on the basis of Parent?

Navnath Kumbhar
Greenhorn

Joined: Mar 07, 2010
Posts: 12
Hi There,
I have Class structure as following


There is Hibernate mapping created for this structure.
Three tables are created for this mapping
tbl_parent
tbl_lstChild
tbl_child

Now I want to fetch Child object where I have parent object with me.
Query in simple SQL is
select * from tbl_child tc inner join tbl_lstChild tlc on
tc.id=tlc.child_id where tlc.id=123
Above query is working fine.
Now How do I write same query in Hibernate(HQL)?
Please hel me

Thank You in advance.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Could you show your query and tell us why it is not working (properly)?


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Navnath Kumbhar
Greenhorn

Joined: Mar 07, 2010
Posts: 12
Hi,

Thanks for replay.
I have resolved it.
Query is
select lc from Parent p inner join p.lstChild lc where p.strId=? and lc.name=?

Thank You.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to write HQL to retrive Child object(From list) on the basis of Parent?
 
Similar Threads
So much on the Left Joins in Hibernate
How does Hibernate get child objects
retrieving object hierarchy - many-to-one?
Hibernate mapping a self referencing object
outer join in HQL