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 :)
|