-->
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: Current table alias in Filter ($FILTER_PLACEHOLDER Hack)
PostPosted: Wed Aug 10, 2011 11:26 am 
Newbie

Joined: Mon Apr 18, 2011 6:51 am
Posts: 4
Hi,

i want to use the hibernate filter feature and defined a filter definition for my class.

Code:
@Entity
@FilterDef(name = "branchFilter",
      defaultCondition = "_branchId = :branchId",
      parameters = @ParamDef(name = "branchId", type = "long"))
@Filter(name = "branchFilter")
public class WheelStorage extends BaseEntity {
...
}

But i getting the error that the column _branchId is ambiguous (because of a outer join).

In the server log we can see that hibernate not use the current table alias (this_) for
the column _branchId:

Code:
17:08:18,365 INFO  [STDOUT]     where
17:08:18,365 INFO  [STDOUT]         this_._branchId = ?

I also tried:

Code:
defaultCondition = ":branchId = _branchId"

After a lot of failed tries to include the current alias in the defaultCondition i found the
following solution:

Code:
@FilterDef(name = "branchFilter",
      defaultCondition = "$FILTER_PLACEHOLDER$._branchId = :branchId",
      parameters = @ParamDef(name = "branchId", type = "long"))

$FILTER_PLACEHOLDER$ is defined in the FilterIml class and will be replaced by the
FilterHelper class with current table alias!

Although this hack works fine, i cannot imagine that this is the right way to get the
current table alias in the defaultCondition.

Any suggestions?


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.