-->
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.  [ 2 posts ] 
Author Message
 Post subject: Alias and FilterJoinTable
PostPosted: Thu Aug 02, 2012 7:41 am 
Newbie

Joined: Thu Aug 02, 2012 7:21 am
Posts: 1
Hello,

Is there a way to access attributes of an entity in a @FilterJoinTable clause ?

Something like :

Code:
class Bar{

@ManyToMany(cascade = CascadeType.ALL)
@FilterJoinTable(name = "fooFilter", condition = "foos_id in (select o.foo_id from Other o where o.bar_id = {alias}.id))
List<Foo> foos;

@Id
Long id;
}


I tried to use latest 4.1.5.SP1 version (cf. this discussion: http://www.mailinglistarchive.com/html/hibernate-dev@lists.jboss.org/2012-06/msg00018.html) and SqlFragmentAlias, no success (The problem remains : {alias} refers to the join table(Bar_Foo), not to the root Bar entity).

Thanks !


Top
 Profile  
 
 Post subject: Re: Alias and FilterJoinTable
PostPosted: Tue Aug 28, 2012 10:36 am 
Newbie

Joined: Thu Mar 31, 2005 5:01 pm
Posts: 16
The Bar entity is not included in the SQL generated for resolving the many-to-many, so you're not going to be able to access it.

But the ID you need is in the join table (Bar_Foo.BAR_ID), so this will work:

Code:
   
@FilterJoinTable(name="fooFilter", condition="{f}.foos_id in(select o.foo_id from Other o where o.bar_id = {f}.bar_id)",
      aliases={@SqlFragmentAlias(alias="f",table="Bar_Foo")})


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