-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Load Parent with Children filtering by Child column(s)
PostPosted: Wed Dec 12, 2007 1:30 pm 
Beginner
Beginner

Joined: Tue Nov 27, 2007 1:25 pm
Posts: 24
Target:
Load Parent with Children filtering by Child column(s).

Problem:
NHibernate creates join for Children, i.e. select * from Parent p left join Children c on p.ParentId = c.ParentId where c.Name like 'John%', so if Parent has one than more Child, duplicate Parent records will be loaded.

Is there any way to do this..?

Regards,
Mindaugas


Top
 Profile  
 
 Post subject: Re: Load Parent with Children filtering by Child column(s)
PostPosted: Thu Dec 13, 2007 4:26 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Use an 'in':

Code:
from Parent p where p.ParentId in ( select ParentId from Children where Name like 'John%')


Additions can be made for eagerly loading children. This can also be done with Criteria.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.