-->
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: Is it possible to filter a collection within a criteria?
PostPosted: Mon Jul 12, 2004 2:28 pm 
Newbie

Joined: Mon Jun 28, 2004 12:28 pm
Posts: 3
Location: Virginia
I have a parent/child relationship where I want to use a criteria query to find results based on attributes within the children. Then I want to return the matching parents with their children filtered to only the matching children. Is this possible?

So let's say the child class that has an attribute of hairColor. I want to search for parent objects where they have children with brown hair and return those parents with the children collection filtered to only have children with brown hair.

I have no problem creating the criteria query to narrow the parent objects to ones with children with brown hair, but I don't know how to filter the children collection. I have searched the docs and read about filtering, but it appears to require a query and not a criteria. Is it possible to create a filter using a criteria?

Thanks for the help.

BTW - I am using Hibernate 2.1.4.

- James


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 10:15 am 
Beginner
Beginner

Joined: Fri Mar 26, 2004 8:19 am
Posts: 49
One thing you could do is map children to be lazy, then while your session is open, return your children collection, then filter this collection (which does work on a lazy collection), then call Hibernate.initialize on the resulting child collection.

Best,
Toastchee
[/quote]


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.