While this is not documented anywhere that I can find, it is in fact possible to use filter parameters in conditions other than those defined in the filter.
For example, one might define a class with the following annotation
Code:
@FilterDef(name = "foo", parameters = {@ParamDef(name = "asOfDate", type = "timestamp")})
If that filter is enabled on the session, queries may be written that use the bind variable
:foo.asOfDate.
In fact, it is possible to use this parameter within a class level
where annotation. Of course, this all assumes that the filter will always be enabled, and the parameters will always have values for all sessions.
Code:
@Where(clause = ":foo.asOfDate BETWEEN eff_start_dt and eff_end_dt")
The question is... is this a feature or a hack? Can support for this be expected in future releases.
Note that I would like to do something similar to what is being described here
http://lists.jboss.org/pipermail/hibernate-dev/2006-September/000294.html