FileDocCategorySizeDatePackage
Restrictions.javaAPI DocHibernate 3.2.510470Thu Aug 11 02:26:26 BST 2005org.hibernate.criterion

Restrictions

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
org.hibernate.Criteria
see
Projections factory methods for Projection instances
author
Gavin King

Fields Summary
Constructors Summary
Restrictions()

		//cannot be instantiated
	
Methods Summary
public static CriterionallEq(java.util.Map propertyNameValues)
Apply an "equals" constraint to each property in the key set of a Map

param
propertyNameValues a map from property names to values
return
Criterion

		Conjunction conj = conjunction();
		Iterator iter = propertyNameValues.entrySet().iterator();
		while ( iter.hasNext() ) {
			Map.Entry me = (Map.Entry) iter.next();
			conj.add( eq( (String) me.getKey(), me.getValue() ) );
		}
		return conj;
	
public static LogicalExpressionand(Criterion lhs, Criterion rhs)
Return the conjuction of two expressions

param
lhs
param
rhs
return
Criterion

		return new LogicalExpression(lhs, rhs, "and");
	
public static Criterionbetween(java.lang.String propertyName, java.lang.Object lo, java.lang.Object hi)
Apply a "between" constraint to the named property

param
propertyName
param
lo value
param
hi value
return
Criterion

		return new BetweenExpression(propertyName, lo, hi);
	
public static Conjunctionconjunction()
Group expressions together in a single conjunction (A and B and C...)

return
Conjunction

		return new Conjunction();
	
public static Disjunctiondisjunction()
Group expressions together in a single disjunction (A or B or C...)

return
Conjunction

		return new Disjunction();
	
public static SimpleExpressioneq(java.lang.String propertyName, java.lang.Object value)
Apply an "equal" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, "=");
	
public static PropertyExpressioneqProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply an "equal" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, "=");
	
public static SimpleExpressionge(java.lang.String propertyName, java.lang.Object value)
Apply a "greater than or equal" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, ">=");
	
public static PropertyExpressiongeProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply a "greater than or equal" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, ">=");
	
public static SimpleExpressiongt(java.lang.String propertyName, java.lang.Object value)
Apply a "greater than" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, ">");
	
public static PropertyExpressiongtProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply a "greater than" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, ">");
	
public static CriterionidEq(java.lang.Object value)
Apply an "equal" constraint to the identifier property

param
propertyName
param
value
return
Criterion

		return new IdentifierEqExpression(value);
	
public static Criterionilike(java.lang.String propertyName, java.lang.String value, MatchMode matchMode)
A case-insensitive "like", similar to Postgres ilike operator

param
propertyName
param
value
return
Criterion

		return new IlikeExpression(propertyName, value, matchMode);
	
public static Criterionilike(java.lang.String propertyName, java.lang.Object value)
A case-insensitive "like", similar to Postgres ilike operator

param
propertyName
param
value
return
Criterion

		return new IlikeExpression(propertyName, value);
	
public static Criterionin(java.lang.String propertyName, java.lang.Object[] values)
Apply an "in" constraint to the named property

param
propertyName
param
values
return
Criterion

		return new InExpression(propertyName, values);
	
public static Criterionin(java.lang.String propertyName, java.util.Collection values)
Apply an "in" constraint to the named property

param
propertyName
param
values
return
Criterion

		return new InExpression( propertyName, values.toArray() );
	
public static CriterionisEmpty(java.lang.String propertyName)
Constrain a collection valued property to be empty

		return new EmptyExpression(propertyName);
	
public static CriterionisNotEmpty(java.lang.String propertyName)
Constrain a collection valued property to be non-empty

		return new NotEmptyExpression(propertyName);
	
public static CriterionisNotNull(java.lang.String propertyName)
Apply an "is not null" constraint to the named property

return
Criterion

		return new NotNullExpression(propertyName);
	
public static CriterionisNull(java.lang.String propertyName)
Apply an "is null" constraint to the named property

return
Criterion

		return new NullExpression(propertyName);
	
public static SimpleExpressionle(java.lang.String propertyName, java.lang.Object value)
Apply a "less than or equal" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, "<=");
	
public static PropertyExpressionleProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply a "less than or equal" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, "<=");
	
public static SimpleExpressionlike(java.lang.String propertyName, java.lang.Object value)
Apply a "like" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, " like ");
	
public static SimpleExpressionlike(java.lang.String propertyName, java.lang.String value, MatchMode matchMode)
Apply a "like" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, matchMode.toMatchString(value), " like " );
	
public static SimpleExpressionlt(java.lang.String propertyName, java.lang.Object value)
Apply a "less than" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, "<");
	
public static PropertyExpressionltProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply a "less than" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, "<");
	
public static NaturalIdentifiernaturalId()

		return new NaturalIdentifier();
	
public static SimpleExpressionne(java.lang.String propertyName, java.lang.Object value)
Apply a "not equal" constraint to the named property

param
propertyName
param
value
return
Criterion

		return new SimpleExpression(propertyName, value, "<>");
	
public static PropertyExpressionneProperty(java.lang.String propertyName, java.lang.String otherPropertyName)
Apply a "not equal" constraint to two properties

		return new PropertyExpression(propertyName, otherPropertyName, "<>");
	
public static Criterionnot(Criterion expression)
Return the negation of an expression

param
expression
return
Criterion

		return new NotExpression(expression);
	
public static LogicalExpressionor(Criterion lhs, Criterion rhs)
Return the disjuction of two expressions

param
lhs
param
rhs
return
Criterion

		return new LogicalExpression(lhs, rhs, "or");
	
public static CriterionsizeEq(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, "=");
	
public static CriterionsizeGe(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, "<=");
	
public static CriterionsizeGt(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, "<");
	
public static CriterionsizeLe(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, ">=");
	
public static CriterionsizeLt(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, ">");
	
public static CriterionsizeNe(java.lang.String propertyName, int size)
Constrain a collection valued property by size

		return new SizeExpression(propertyName, size, "<>");
	
public static CriterionsqlRestriction(java.lang.String sql, java.lang.Object[] values, org.hibernate.type.Type[] types)
Apply a constraint expressed in SQL, with the given JDBC parameters. Any occurrences of {alias} will be replaced by the table alias.

param
sql
param
values
param
types
return
Criterion

		return new SQLCriterion(sql, values, types);
	
public static CriterionsqlRestriction(java.lang.String sql, java.lang.Object value, org.hibernate.type.Type type)
Apply a constraint expressed in SQL, with the given JDBC parameter. Any occurrences of {alias} will be replaced by the table alias.

param
sql
param
value
param
type
return
Criterion

		return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
	
public static CriterionsqlRestriction(java.lang.String sql)
Apply a constraint expressed in SQL. Any occurrences of {alias} will be replaced by the table alias.

param
sql
return
Criterion

		return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);