Package org.hibernate
Interface Filter
- All Known Implementing Classes:
FilterImpl
public interfaceFilterAllows control over an enabledfilter at runtime. In particular, allowsarguments to be assigned to parameters declared by the filter.A filter may be defined using the annotations
@FilterDefand@Filter, but must be explicitly enabled at runtime by callingSession.enableFilter(String), unless the filter is declared asauto-enabled. If, in a given session, a filter not declaredautoEnabled = trueis not explicitly enabled by callingenableFilter(), the filter will have no effect in that session.Everyparameter of the filter must be supplied an argument by calling
setParameter()immediately afterenableFilter()is called, and before any other operation of the session is invoked.
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description FilterDefinitiongetFilterDefinition()Deprecated.There is no plan to remove this operation, but its use should be avoided sinceFilterDefinitionis an SPI type, and so this operation is a layer-breaker.StringgetName()Get the name of this filter.booleanisAppliedToLoadByKey()Get the associatedapplyToLoadByKeyof this named filter.booleanisAutoEnabled()Get the associatedautoEnabledof this named filter.FiltersetParameter(String name,Object value)Set the named parameter's value for this filter.FiltersetParameterList(String name,Object[] values)Set the named parameter's value list for this filter.FiltersetParameterList(String name,Collection<?> values)Set the named parameter's value list for this filter.voidvalidate()Perform validation of the filter state.
Method Detail
getName
String getName()
Get the name of this filter.- Returns:
- This filter's name.
getFilterDefinition
@Deprecated(since="6.2")FilterDefinition getFilterDefinition()
Deprecated.There is no plan to remove this operation, but its use should be avoided sinceFilterDefinitionis an SPI type, and so this operation is a layer-breaker.Get the associateddefinitionof this named filter.- Returns:
- The filter definition
setParameter
Filter setParameter(String name,Object value)
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
Filter setParameterList(String name,Collection<?> values)
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
Filter setParameterList(String name,Object[] values)
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
void validate() throwsHibernateException
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 associatedautoEnabledof this named filter.- Returns:
- The flag value
isAppliedToLoadByKey
boolean isAppliedToLoadByKey()
Get the associatedapplyToLoadByKeyof this named filter.- Returns:
- The flag value