-->
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.  [ 1 post ] 
Author Message
 Post subject: populating children from subcriteria
PostPosted: Fri Dec 24, 2010 2:47 pm 
Newbie

Joined: Fri Dec 17, 2010 7:05 am
Posts: 5
Merry Christmas everyone,

I have an advanced search feature in which you can specify search criteria for the root object's children and their children and so on...

What I want to do is have Hibernate return a List of root objects which are populated only with children that meet the search criteria.

For example, if my root object is Planet and I have a set of Alien objects, someone might want to search for Aliens with blue eyes. I want the results to return a List of all Planets that contain Aliens with blue eyes but I only want the set of Aliens in each Planet to be populated with the ones that have blue eyes. So, if a planet has no Aliens with blue eyes it won't show up, if it has some aliens with blue eyes and some with black eyes, the Planet will show up on the results but it will only be populated with the Aliens that have blue eyes.

I could have Hibernate return all the results but I think they would contain all planets that have aliens with blue eyes but also populated with aliens with black eyes. I could then go through the results in Java and re-apply the search criteria to filter the results but it seems like a waste of time, can Hibernate do this?

I am using the criteria API and Projections.distinct. At the moment I am using an aliasToBean results transformer.

Any help would be greatly appreciated :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.