Package org.hibernate
Interface Filter
- All Known Implementing Classes:
FilterImpl
public interface Filter
Allows control over an enabled filter at runtime.
In particular, allows arguments
to be assigned to parameters declared by the filter.
A filter may be defined using the annotations @FilterDef
and @Filter
, but must be explicitly
enabled at runtime by calling SharedSessionContract.enableFilter(String)
, unless
the filter is declared as auto-enabled.
If, in a given session, a filter not declared autoEnabled = true
is
not explicitly enabled by calling enableFilter()
, the filter will
have no effect in that session.
Every parameter of the filter must be
supplied an argument by calling setParameter()
immediately after
enableFilter()
is called, and before any other operation of the
session is invoked.
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.getName()
Get the name of this filter.getParameterValue
(String name) Obtain the argument currently bound to the filter parameter with the given name.boolean
Get the associatedapplyToLoadByKey
of this named filter.boolean
Get the associatedautoEnabled
of this named filter.setParameter
(String name, Object value) Set the named parameter's value for this filter.setParameterList
(String name, Object[] values) Set the named parameter's value list for this filter.setParameterList
(String name, Collection<?> values) Set the named parameter's value list for this filter.void
validate()
Perform validation of the filter state.
-
Method Details
-
getName
String getName()Get the name of this filter.- Returns:
- This filter's name.
-
getFilterDefinition
Deprecated.There is no plan to remove this operation, but its use should be avoided sinceFilterDefinition
is an SPI type, and so this operation is a layer-breaker.Get the associateddefinition
of this named filter.- Returns:
- The filter definition
-
setParameter
Set the named parameter's value for this filter.- Parameters:
name
- The parameter's name.value
- The value to be applied.- Returns:
- This FilterImpl instance (for method chaining).
-
setParameterList
Set the named parameter's value list for this filter. Used in conjunction with IN-style filter criteria.- Parameters:
name
- The parameter's name.values
- The values to be expanded into an SQL IN list.- Returns:
- This FilterImpl instance (for method chaining).
-
setParameterList
Set the named parameter's value list for this filter. Used in conjunction with IN-style filter criteria.- Parameters:
name
- The parameter's name.values
- The values to be expanded into an SQL IN list.- Returns:
- This FilterImpl instance (for method chaining).
-
validate
Perform validation of the filter state. This is used to verify the state of the filter after its enablement and before its use.- Throws:
HibernateException
- If the state is not currently valid.
-
isAutoEnabled
boolean isAutoEnabled()Get the associatedautoEnabled
of this named filter.- Returns:
- The flag value
-
isAppliedToLoadByKey
boolean isAppliedToLoadByKey()Get the associatedapplyToLoadByKey
of this named filter.- Returns:
- The flag value
-
getParameterValue
Obtain the argument currently bound to the filter parameter with the given name.- Parameters:
name
- the name of the filter parameter- Returns:
- the value currently set
- Since:
- 7
-
FilterDefinition
is an SPI type, and so this operation is a layer-breaker.