Package org.hibernate.annotations
Annotation Type Filter
-
@Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) @Repeatable(Filters.class) public @interface Filter
Specifies that an entity or collection is affected by a named filter declared using@FilterDef, and allows the default filter condition to be overridden for the annotated entity or collection role.For example, we might apply a filter named
Currentto an entity like this:@Entity @Filter(name = "Current", deduceAliasInjectionPoints = false, condition = "{alias}.year = extract(year from current_date)") class Course { @Id @GeneratedValue Long id; int year; ... }If an entity or collection has no
@Filterannotation with the name of a given filter, it is not affected by that filter.- See Also:
FilterJoinTable,DialectOverride.Filters
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description SqlFragmentAlias[]aliasesExplicitly specifies how aliases are interpolated into thecondition()SQL expression.StringconditionThe filter condition, a SQL expression used for filtering the rows returned by a query when the filter is enabled.booleandeduceAliasInjectionPointsDetermines how tables aliases are interpolated into thecondition()SQL expression.
-
-
-
-
condition
String condition
The filter condition, a SQL expression used for filtering the rows returned by a query when the filter is enabled. If not specified, the default filter condition given byFilterDef.defaultCondition()is used.By default, aliases of filtered tables are automatically interpolated into the filter condition, before any token that looks like a column name. Occasionally, when the interpolation algorithm encounters ambiguity, the process of alias interpolation produces broken SQL. In such cases, alias interpolation may be controlled explicitly using either
deduceAliasInjectionPoints()oraliases().- Default:
- ""
-
-
-
deduceAliasInjectionPoints
boolean deduceAliasInjectionPoints
Determines how tables aliases are interpolated into thecondition()SQL expression.- if
true, and by default, an alias is added automatically to every column occurring in the SQL expression, but - if
false, aliases are only interpolated where an explicit placeholder of form{alias}occurs in the SQL expression. - Finally, if
explicit aliasesare specified, then alias interpolation happens only for the specified aliases.
- Default:
- true
- if
-
-
-
aliases
SqlFragmentAlias[] aliases
Explicitly specifies how aliases are interpolated into thecondition()SQL expression. EachSqlFragmentAliasspecifies a placeholder name and the table whose alias should be interpolated. Placeholders are of form{name}wherenamematches aSqlFragmentAlias.alias().- Default:
- {}
-
-