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?