Can somebody teach me an approach to left join fetch and filter the collection being fetched. In my situation, I have 4 Hibernate mapped Java classes, and there is a one-to-many relation that goes down through all of them in a line. Each class is a collection of another class.
What I want to achieve is that when a collection is being fetched, not all the associated objects should be loaded, but only these meet the condition.
For example, There are Country,City,District, and Street 4 classes. A country has a collection of cities, a city has a collection of districts, and a district has a collection of streets. Now I want query Country with conditions being imposed on it's city,district and street, and the city,district,or street will not be fetched if it dosen't meet the condition. If There is not any city, district and street meet the conditions, their country will not be selected, otherwise the country will be selected, but of which maybe not all child cities, districts and streets be selected. This is what I mean filter the collection.
In the new version hibernate reference, I have noticed a keyword 'with'. It seems useful in my case. Can some one provide me some good suggestions.Thanks in advance.
|