-->
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: how to make a left join fetch query that filter collection
PostPosted: Thu Aug 09, 2007 9:34 am 
Newbie

Joined: Thu Aug 09, 2007 8:29 am
Posts: 4
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.


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.