-->
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: Child collection conditions
PostPosted: Tue Oct 02, 2007 7:53 am 
Newbie

Joined: Tue Oct 02, 2007 7:46 am
Posts: 1
Feeling guilty to ask this, but I've got an object A with a collection of children B..

Given that I select object A with a query, I get the object returned and all of its children.. great..

But given that I want to select a collection of A where it has at least one child that meets my conditions, and not only that, but the children in A must be exactly those that met those conditions..

..in a single query.. does that make sense?

I very much appreciate any help on this, I'll be working on this myself so I'll post my results for the sake of anyone else starting out wanting to do such a query.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 02, 2007 8:21 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
I don't think you can do that directly.

You can do the initial query to get the A objects with criteria on B and then you can use ISession.CreateFilter() to filter the child collection of B objects to to get a list of child objects that only match the filter criteria.

There may be another way, but I'm not aware of it.

Cheers,

Symon.


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.