Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Hibernate query
PostPosted: Thu Dec 15, 2011 6:35 pm 
Newbie

Joined: Thu Dec 15, 2011 6:29 pm
Posts: 1
Hi,

I need to create a hibernate query that can join parent and child table. The relationship between parent and child is 1-to-many. I only need to retrieve the child with the largest id. Using native SQL, I can do the following:
select * from parent p, child c where p.id=c.parent_id and c.id = (select max(id) from child where parent_id=p.id);

I am not very familiar with HQL. Can someone help me translate it to HQL?

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.