类 Restrictions
- java.lang.Object
-
- org.hibernate.criterion.Restrictions
-
- 直接已知子类:
Expression
public class Restrictions extends Object
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 theProjectionsfactory methods for generatingProjectioninstances- 作者:
- Gavin King, Steve Ebersole
- 另请参阅:
Criteria
-
-
构造器概要
构造器 限定符 构造器 说明 protectedRestrictions()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static CriterionallEq(Map<String,?> propertyNameValues)Apply an "equals" constraint to each property in the key set of a Mapstatic Conjunctionand(Criterion... predicates)Return the conjunction of multiple expressionsstatic LogicalExpressionand(Criterion lhs, Criterion rhs)Return the conjunction of two expressionsstatic Criterionbetween(String propertyName, Object low, Object high)Apply a "between" constraint to the named propertystatic Conjunctionconjunction()Group expressions together in a single conjunction (A and B and C...).static Conjunctionconjunction(Criterion... conditions)Group expressions together in a single conjunction (A and B and C...).static Disjunctiondisjunction()Group expressions together in a single disjunction (A or B or C...).static Disjunctiondisjunction(Criterion... conditions)Group expressions together in a single disjunction (A or B or C...).static SimpleExpressioneq(String propertyName, Object value)Apply an "equal" constraint to the named propertystatic CriterioneqOrIsNull(String propertyName, Object value)Apply an "equal" constraint to the named property.static PropertyExpressioneqProperty(String propertyName, String otherPropertyName)Apply an "equal" constraint to two propertiesstatic SimpleExpressionge(String propertyName, Object value)Apply 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 SimpleExpressiongt(String propertyName, Object value)Apply a "greater than" constraint to the named propertystatic PropertyExpressiongtProperty(String propertyName, String otherPropertyName)Apply a "greater than" constraint to two propertiesstatic CriterionidEq(Object value)Apply an "equal" constraint to the identifier propertystatic Criterionilike(String propertyName, Object value)A case-insensitive "like" (similar to Postgres ilike operator)static Criterionilike(String propertyName, String value, MatchMode matchMode)A case-insensitive "like" (similar to Postgres ilike operator) using the provided match modestatic Criterionin(String propertyName, Object... values)Apply an "in" constraint to the named property.static Criterionin(String propertyName, Collection values)Apply an "in" constraint to the named property.static CriterionisEmpty(String propertyName)Constrain a collection valued property to be emptystatic CriterionisNotEmpty(String propertyName)Constrain a collection valued property to be non-emptystatic CriterionisNotNull(String propertyName)Apply an "is not null" constraint to the named propertystatic CriterionisNull(String propertyName)Apply an "is null" constraint to the named propertystatic SimpleExpressionle(String propertyName, Object value)Apply 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 SimpleExpressionlike(String propertyName, Object value)Apply a "like" constraint to the named propertystatic SimpleExpressionlike(String propertyName, String value, MatchMode matchMode)Apply a "like" constraint to the named property using the provided match modestatic SimpleExpressionlt(String propertyName, Object value)Apply a "less than" constraint to the named propertystatic PropertyExpressionltProperty(String propertyName, String otherPropertyName)Apply a "less than" constraint to two propertiesstatic NaturalIdentifiernaturalId()Consider using any of the natural id based loading stuff from session instead, especially in cases where the restriction is the full set of natural id values.static SimpleExpressionne(String propertyName, Object value)Apply a "not equal" constraint to the named propertystatic CriterionneOrIsNotNull(String propertyName, Object value)Apply a "not equal" constraint to the named property.static PropertyExpressionneProperty(String propertyName, String otherPropertyName)Apply a "not equal" constraint to two propertiesstatic Criterionnot(Criterion expression)Return the negation of an expressionstatic Disjunctionor(Criterion... predicates)Return the disjunction of multiple expressionsstatic LogicalExpressionor(Criterion lhs, Criterion rhs)Return the disjunction of two expressionsstatic CriterionsizeEq(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsizeGe(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsizeGt(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsizeLe(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsizeLt(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsizeNe(String propertyName, int size)Constrain a collection valued property by sizestatic CriterionsqlRestriction(String sql)Apply a constraint expressed in SQL with no JDBC parameters.static CriterionsqlRestriction(String sql, Object[] values, Type[] types)Create a restriction expressed in SQL with JDBC parameters.static CriterionsqlRestriction(String sql, Object value, Type type)Create a restriction expressed in SQL with one JDBC parameter.
-
-
-
方法详细资料
-
idEq
public static Criterion idEq(Object value)
Apply an "equal" constraint to the identifier property- 参数:
value- The value to use in comparison- 返回:
- Criterion
- 另请参阅:
IdentifierEqExpression
-
eq
public static SimpleExpression eq(String propertyName, Object value)
Apply an "equal" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- SimpleExpression
- 另请参阅:
SimpleExpression
-
eqOrIsNull
public static Criterion eqOrIsNull(String propertyName, Object value)
Apply an "equal" constraint to the named property. If the value is null, instead apply "is null".- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
eq(java.lang.String, java.lang.Object),isNull(java.lang.String)
-
ne
public static SimpleExpression ne(String propertyName, Object value)
Apply a "not equal" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
neOrIsNotNull
public static Criterion neOrIsNotNull(String propertyName, Object value)
Apply a "not equal" constraint to the named property. If the value is null, instead apply "is not null".- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
ne(java.lang.String, java.lang.Object),isNotNull(java.lang.String)
-
like
public static SimpleExpression like(String propertyName, Object value)
Apply a "like" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
like
public static SimpleExpression like(String propertyName, String value, MatchMode matchMode)
Apply a "like" constraint to the named property using the provided match mode- 参数:
propertyName- The name of the propertyvalue- The value to use in comparisonmatchMode- The match mode to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
ilike
public static Criterion ilike(String propertyName, Object value)
A case-insensitive "like" (similar to Postgres ilike operator)- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
LikeExpression
-
ilike
public static Criterion ilike(String propertyName, String value, MatchMode matchMode)
A case-insensitive "like" (similar to Postgres ilike operator) using the provided match mode- 参数:
propertyName- The name of the propertyvalue- The value to use in comparisonmatchMode- The match mode to use in comparison- 返回:
- The Criterion
- 另请参阅:
LikeExpression
-
gt
public static SimpleExpression gt(String propertyName, Object value)
Apply a "greater than" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
lt
public static SimpleExpression lt(String propertyName, Object value)
Apply a "less than" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
le
public static SimpleExpression le(String propertyName, Object value)
Apply a "less than or equal" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
ge
public static SimpleExpression ge(String propertyName, Object value)
Apply a "greater than or equal" constraint to the named property- 参数:
propertyName- The name of the propertyvalue- The value to use in comparison- 返回:
- The Criterion
- 另请参阅:
SimpleExpression
-
between
public static Criterion between(String propertyName, Object low, Object high)
Apply a "between" constraint to the named property- 参数:
propertyName- The name of the propertylow- The low valuehigh- The high value- 返回:
- The Criterion
- 另请参阅:
BetweenExpression
-
in
public static Criterion in(String propertyName, Object... values)
Apply an "in" constraint to the named property.- 参数:
propertyName- The name of the propertyvalues- The literal values to use in the IN restriction- 返回:
- The Criterion
- 另请参阅:
InExpression
-
in
public static Criterion in(String propertyName, Collection values)
Apply an "in" constraint to the named property.- 参数:
propertyName- The name of the propertyvalues- The literal values to use in the IN restriction- 返回:
- The Criterion
- 另请参阅:
InExpression
-
isNull
public static Criterion isNull(String propertyName)
Apply an "is null" constraint to the named property- 参数:
propertyName- The name of the property- 返回:
- Criterion
- 另请参阅:
NullExpression
-
isNotNull
public static Criterion isNotNull(String propertyName)
Apply an "is not null" constraint to the named property- 参数:
propertyName- The property name- 返回:
- The Criterion
- 另请参阅:
NotNullExpression
-
eqProperty
public static PropertyExpression eqProperty(String propertyName, String otherPropertyName)
Apply an "equal" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
neProperty
public static PropertyExpression neProperty(String propertyName, String otherPropertyName)
Apply a "not equal" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
ltProperty
public static PropertyExpression ltProperty(String propertyName, String otherPropertyName)
Apply a "less than" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
leProperty
public static PropertyExpression leProperty(String propertyName, String otherPropertyName)
Apply a "less than or equal" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
gtProperty
public static PropertyExpression gtProperty(String propertyName, String otherPropertyName)
Apply a "greater than" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
geProperty
public static PropertyExpression geProperty(String propertyName, String otherPropertyName)
Apply a "greater than or equal" constraint to two properties- 参数:
propertyName- One property nameotherPropertyName- The other property name- 返回:
- The Criterion
- 另请参阅:
PropertyExpression
-
and
public static LogicalExpression and(Criterion lhs, Criterion rhs)
Return the conjunction of two expressions- 参数:
lhs- One expressionrhs- The other expression- 返回:
- The Criterion
-
and
public static Conjunction and(Criterion... predicates)
Return the conjunction of multiple expressions- 参数:
predicates- The predicates making up the initial junction- 返回:
- The conjunction
-
or
public static LogicalExpression or(Criterion lhs, Criterion rhs)
Return the disjunction of two expressions- 参数:
lhs- One expressionrhs- The other expression- 返回:
- The Criterion
-
or
public static Disjunction or(Criterion... predicates)
Return the disjunction of multiple expressions- 参数:
predicates- The predicates making up the initial junction- 返回:
- The conjunction
-
not
public static Criterion not(Criterion expression)
Return the negation of an expression- 参数:
expression- The expression to be negated- 返回:
- Criterion
- 另请参阅:
NotExpression
-
sqlRestriction
public static Criterion sqlRestriction(String sql, Object[] values, Type[] types)
Create a restriction expressed in SQL with JDBC parameters. Any occurrences of {alias} will be replaced by the table alias.- 参数:
sql- The SQL restrictionvalues- The parameter valuestypes- The parameter types- 返回:
- The Criterion
- 另请参阅:
SQLCriterion
-
sqlRestriction
public static Criterion sqlRestriction(String sql, Object value, Type type)
Create a restriction expressed in SQL with one JDBC parameter. Any occurrences of {alias} will be replaced by the table alias.- 参数:
sql- The SQL restrictionvalue- The parameter valuetype- The parameter type- 返回:
- The Criterion
- 另请参阅:
SQLCriterion
-
sqlRestriction
public static Criterion sqlRestriction(String sql)
Apply a constraint expressed in SQL with no JDBC parameters. Any occurrences of {alias} will be replaced by the table alias.- 参数:
sql- The SQL restriction- 返回:
- The Criterion
- 另请参阅:
SQLCriterion
-
conjunction
public static Conjunction conjunction()
Group expressions together in a single conjunction (A and B and C...). This form creates an empty conjunction. SeeJunction.add(Criterion)- 返回:
- Conjunction
-
conjunction
public static Conjunction conjunction(Criterion... conditions)
Group expressions together in a single conjunction (A and B and C...).- 参数:
conditions- The initial set of conditions to put into the Conjunction- 返回:
- Conjunction
-
disjunction
public static Disjunction disjunction()
Group expressions together in a single disjunction (A or B or C...). This form creates an empty disjunction. SeeJunction.add(Criterion)- 返回:
- Conjunction
-
disjunction
public static Disjunction disjunction(Criterion... conditions)
Group expressions together in a single disjunction (A or B or C...).- 参数:
conditions- The initial set of conditions to put into the Disjunction- 返回:
- Conjunction
-
allEq
public static Criterion allEq(Map<String,?> propertyNameValues)
Apply an "equals" constraint to each property in the key set of a Map- 参数:
propertyNameValues- a map from property names to values- 返回:
- Criterion
- 另请参阅:
Conjunction
-
isEmpty
public static Criterion isEmpty(String propertyName)
Constrain a collection valued property to be empty- 参数:
propertyName- The name of the collection property- 返回:
- The Criterion
- 另请参阅:
EmptyExpression
-
isNotEmpty
public static Criterion isNotEmpty(String propertyName)
Constrain a collection valued property to be non-empty- 参数:
propertyName- The name of the collection property- 返回:
- The Criterion
- 另请参阅:
NotEmptyExpression
-
sizeEq
public static Criterion sizeEq(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
sizeNe
public static Criterion sizeNe(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
sizeGt
public static Criterion sizeGt(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
sizeLt
public static Criterion sizeLt(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
sizeGe
public static Criterion sizeGe(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
sizeLe
public static Criterion sizeLe(String propertyName, int size)
Constrain a collection valued property by size- 参数:
propertyName- The name of the collection propertysize- The size to use in comparison- 返回:
- The Criterion
- 另请参阅:
SizeExpression
-
naturalId
public static NaturalIdentifier naturalId()
Consider using any of the natural id based loading stuff from session instead, especially in cases where the restriction is the full set of natural id values.
-
-