-->
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.  [ 6 posts ] 
Author Message
 Post subject: Filter not applied to Many-To-Many set
PostPosted: Tue Nov 22, 2005 6:12 am 
Newbie

Joined: Tue Nov 22, 2005 6:04 am
Posts: 4
Got in entity, say X with

@FilterDef(name = "filter", parameters = { @ParamDef(name = "falseVal", type = "integer") })

@Filters({ @Filter(name = "filter", condition = "(:falseVal = rating)") })


I have another entity Y that has a Set of X that is mapped with a
@ManyToMany annotation, a join table is used to the relation.

When i retrieve the entity from a "from X ....." the filter works just fine

But, when i do Y.getX() the collection is initialized without the filter applied !

Any way to apply the filter ?

I've tried setting the filter to the collection mapping but get an SQLException because Hibernate tries to apply the filter to the join table no to the table containing the entity.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well in the mapping file, you'd do this by attaching the filter to the <many-to-many/> element as opposed to the <set/> element. Not sure if this is available yet in the annotations. Emmanuel?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 5:12 am 
Newbie

Joined: Tue Nov 22, 2005 6:04 am
Posts: 4
Yes thereis a @Filter annotation but as i said Hibernate tries to apply the "where filerColumn=?" on the join table, not on the table that contains the actual entity.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 9:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
you miss the point. For many-to-many collections, in the mapping files you can attach the filter in two different places. One affects the association table; the other affects the "target table".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 8:50 am 
Newbie

Joined: Tue Nov 22, 2005 6:04 am
Posts: 4
I dont use ANY mapping files, only annotations.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 2:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
right, hence my comments in my initial response. So really, then, this is a question/post that belongs in the "EJB 3.0 Persistence (JSR-220)" forum.


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