Package org.hibernate.criterion
Class Restrictions
java.lang.Object
org.hibernate.criterion.Restrictions
- Direct Known Subclasses:
Expression
The criterion package may be used by applications as a framework for building
new kinds of Criterion. However, it is intended that most applications will
simply use the built-in criterion types via the static factory methods of this class.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic CriterionApply an "equals" constraint to each property in the key set of a Mapstatic LogicalExpressionReturn the conjuction of two expressionsstatic CriterionApply a "between" constraint to the named propertystatic ConjunctionGroup expressions together in a single conjunction (A and B and C...)static DisjunctionGroup expressions together in a single disjunction (A or B or C...)static SimpleExpressionApply an "equal" constraint to the named propertystatic PropertyExpressioneqProperty(String propertyName, String otherPropertyName) Apply an "equal" constraint to two propertiesstatic SimpleExpressionApply a "greater than or equal" constraint to the named propertystatic PropertyExpressiongeProperty(String propertyName, String otherPropertyName) Apply a "greater than or equal" constraint to two propertiesstatic SimpleExpressionApply a "greater than" constraint to the named propertystatic PropertyExpressiongtProperty(String propertyName, String otherPropertyName) Apply a "greater than" constraint to two propertiesstatic CriterionApply an "equal" constraint to the identifier propertystatic CriterionA case-insensitive "like", similar to Postgres ilike operatorstatic CriterionA case-insensitive "like", similar to Postgres ilike operatorstatic CriterionApply an "in" constraint to the named propertystatic Criterionin(String propertyName, Collection values) Apply an "in" constraint to the named propertystatic CriterionConstrain a collection valued property to be emptystatic CriterionisNotEmpty(String propertyName) Constrain a collection valued property to be non-emptystatic CriterionApply an "is not null" constraint to the named propertystatic CriterionApply an "is null" constraint to the named propertystatic SimpleExpressionApply a "less than or equal" constraint to the named propertystatic PropertyExpressionleProperty(String propertyName, String otherPropertyName) Apply a "less than or equal" constraint to two propertiesstatic SimpleExpressionApply a "like" constraint to the named propertystatic SimpleExpressionApply a "like" constraint to the named propertystatic SimpleExpressionApply a "less than" constraint to the named propertystatic PropertyExpressionltProperty(String propertyName, String otherPropertyName) Apply a "less than" constraint to two propertiesstatic NaturalIdentifierstatic SimpleExpressionApply a "not equal" constraint to the named propertystatic PropertyExpressionneProperty(String propertyName, String otherPropertyName) Apply a "not equal" constraint to two propertiesstatic CriterionReturn the negation of an expressionstatic LogicalExpressionReturn the disjuction of two expressionsstatic CriterionConstrain a collection valued property by sizestatic CriterionConstrain a collection valued property by sizestatic CriterionConstrain a collection valued property by sizestatic CriterionConstrain a collection valued property by sizestatic CriterionConstrain a collection valued property by sizestatic CriterionConstrain a collection valued property by sizestatic CriterionsqlRestriction(String sql) Apply a constraint expressed in SQL.static CriterionsqlRestriction(String sql, Object[] values, Type[] types) Apply a constraint expressed in SQL, with the given JDBC parameters.static CriterionsqlRestriction(String sql, Object value, Type type) Apply a constraint expressed in SQL, with the given JDBC parameter.
-
Method Details
-
idEq
Apply an "equal" constraint to the identifier property- Parameters:
value-propertyName-- Returns:
- Criterion
-
eq
Apply an "equal" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
ne
Apply a "not equal" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
like
Apply a "like" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
like
Apply a "like" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
ilike
A case-insensitive "like", similar to Postgres ilike operator- Parameters:
propertyName-value-- Returns:
- Criterion
-
ilike
A case-insensitive "like", similar to Postgres ilike operator- Parameters:
propertyName-value-- Returns:
- Criterion
-
gt
Apply a "greater than" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
lt
Apply a "less than" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
le
Apply a "less than or equal" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
ge
Apply a "greater than or equal" constraint to the named property- Parameters:
propertyName-value-- Returns:
- Criterion
-
between
Apply a "between" constraint to the named property- Parameters:
propertyName-lo- valuehi- value- Returns:
- Criterion
-
in
Apply an "in" constraint to the named property- Parameters:
propertyName-values-- Returns:
- Criterion
-
in
Apply an "in" constraint to the named property- Parameters:
propertyName-values-- Returns:
- Criterion
-
isNull
Apply an "is null" constraint to the named property- Returns:
- Criterion
-
eqProperty
Apply an "equal" constraint to two properties -
neProperty
Apply a "not equal" constraint to two properties -
ltProperty
Apply a "less than" constraint to two properties -
leProperty
Apply a "less than or equal" constraint to two properties -
gtProperty
Apply a "greater than" constraint to two properties -
geProperty
Apply a "greater than or equal" constraint to two properties -
isNotNull
Apply an "is not null" constraint to the named property- Returns:
- Criterion
-
and
Return the conjuction of two expressions- Parameters:
lhs-rhs-- Returns:
- Criterion
-
or
Return the disjuction of two expressions- Parameters:
lhs-rhs-- Returns:
- Criterion
-
not
Return the negation of an expression- Parameters:
expression-- Returns:
- Criterion
-
sqlRestriction
Apply a constraint expressed in SQL, with the given JDBC parameters. Any occurrences of {alias} will be replaced by the table alias.- Parameters:
sql-values-types-- Returns:
- Criterion
-
sqlRestriction
Apply a constraint expressed in SQL, with the given JDBC parameter. Any occurrences of {alias} will be replaced by the table alias.- Parameters:
sql-value-type-- Returns:
- Criterion
-
sqlRestriction
Apply a constraint expressed in SQL. Any occurrences of {alias} will be replaced by the table alias.- Parameters:
sql-- Returns:
- Criterion
-
conjunction
Group expressions together in a single conjunction (A and B and C...)- Returns:
- Conjunction
-
disjunction
Group expressions together in a single disjunction (A or B or C...)- Returns:
- Conjunction
-
allEq
Apply an "equals" constraint to each property in the key set of a Map- Parameters:
propertyNameValues- a map from property names to values- Returns:
- Criterion
-
isEmpty
Constrain a collection valued property to be empty -
isNotEmpty
Constrain a collection valued property to be non-empty -
sizeEq
Constrain a collection valued property by size -
sizeNe
Constrain a collection valued property by size -
sizeGt
Constrain a collection valued property by size -
sizeLt
Constrain a collection valued property by size -
sizeGe
Constrain a collection valued property by size -
sizeLe
Constrain a collection valued property by size -
naturalId
-