-->
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.  [ 4 posts ] 
Author Message
 Post subject: Filtering Sets or Lists within Parent Objects
PostPosted: Mon Jan 09, 2006 5:20 pm 
Newbie

Joined: Mon Jan 09, 2006 5:06 pm
Posts: 3
Hello I have been really loving hibernate. My only problem now is I need to filter a collection/set that belongs to a parent class. The parent class has a set of child objects that need to be filtered based on another table. The problem is the <filter> tags have a condition statement that seems to only work with fields within the child table, not a table that joins with it. So is it possible to filter objects in a collection by declaring it as a list instead of a set and using the index function on the collection ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 5:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can use a subselect in the filter condition.


Top
 Profile  
 
 Post subject: great
PostPosted: Mon Jan 09, 2006 5:41 pm 
Newbie

Joined: Mon Jan 09, 2006 5:06 pm
Posts: 3
Ok awesome um the only problem is I have been having difficulty with getting the subselect to work with the set. what is the syntax?


<set name="tireProducts" lazy="false" inverse="true" >
<subselect>select id,prod_id from ModelYearProduct myp</subselect>

<key column="tire_model"/>

<one-to-many class="com.tiresport.dataobject.TireProductDO" />

<filter name="makeYearVehicleFilter"
condition="tireproduc0_.prod_id = myp.prod_id and
myp.id = :makeYearVehicleParam"/>
</set>



If you see my subselect I need the id field from the ModelYearProduct table which joins with the child TireProduct table through the prod_id field. That id field represents a make, year and vehicle pair that links with a product.


Top
 Profile  
 
 Post subject: alias issue
PostPosted: Mon Jan 09, 2006 5:43 pm 
Newbie

Joined: Mon Jan 09, 2006 5:06 pm
Posts: 3
When I tried fetching the set it had a problem because the subselect wasn't being called and it couldn't find the alias 'myp'.


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