I have a hibernate filter that needs to evaluate using two different columns in the database. I have another existing hibernate object that contains both of those fields, and I would like to be able to pass the other hibernate object into the session.enableFilter.setParameter() call, rather than pass both the values contained in it separately.
Specifically, I would like to replace this code:
session
.enableFilter("inLocation")
.setParameter("traversalLeft", 5)
.setParameter("traversalRight", 10);
with this code:
session
.enableFilter("inLocation")
.setParameter("location", locationHibernateObject)
to better insulate excactly what the filter needs.
But when I try to configure the filter like:
@FilterDef(name="inLocation", parameters=@ParamDef( name="location", type="com.example.Location" ) )
@Filters( {
@Filter(name="inLocation", condition="current_location_id in (select location.id from location where location.traversal_left between :location.traversalLeft+1 and :location.traversalRight)")
} )
public class ClassToFilter {
I get an error trying to call enableFilter()
Is this something that is even possible? What am I doing wrong?