Generally you will only need to use this object for creating OR, JUNCTION or
CONJUNCTION expressions. To create simple expressions you will most likely
just use the methods on the ExpressionList object that is returned via
Query.where().
This provides a convenient way to create expressions for the default database.
See also DB.expressionFactory()
Creates standard common expressions for using in a Query Where or Having clause.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExpressionAll Equal - Map containing property names and their values.static Expressionand(Expression expOne, Expression expTwo) And - join two expressions with a logical and.static ExpressionBetween - property between the two given values.static ExpressionBetween - value between two given properties.static <T> Junction<T>conjunction(Query<T> query) Return a list of expressions that will be joined by AND's.static ExpressionContains - property like %value%.static <T> Junction<T>disjunction(Query<T> query) Return a list of expressions that will be joined by OR's.static ExpressionEnds With - property like %value.static ExpressionEqual To - property equal to the given value.static ExampleExpressionexampleLike(Object example) Create the query by Example expression which is case sensitive and using LikeType.RAW (you need to add you own wildcards % and _).static ExampleExpressionexampleLike(Object example, boolean caseInsensitive, LikeType likeType) Create the query by Example expression specifying more options.static ExpressionGreater Than or Equal to - property greater than or equal to the given value.static ExpressionGreater Than - property greater than the given value.static ExpressionCase insensitive Contains - property like %value%.static ExpressionId Equal to - ID property is equal to the value.static ExpressionCase insensitive Ends With - property like %value.static ExpressionCase Insensitive Equal To - property equal to the given value (typically using a lower() function to make it case insensitive).static ExampleExpressioniexampleLike(Object example) Case insensitiveexampleLike(Object)static ExpressionCase insensitive Like - property like value where the value contains the SQL wild card characters % (percentage) and _ (underscore).static ExpressionIn - using a subQuery.static ExpressionIn - property has a value in the array of values.static Expressionin(String propertyName, Collection<?> values) In - property has a value in the collection of values.static ExpressioninOrEmpty(String propertyName, Collection<?> values) In where null or empty values means that no predicate is added to the query.static ExpressionIn Range -property >= value1 and property < value2.static ExpressionFor collection properties that are empty (have not existing elements).static ExpressionisNotEmpty(String propertyName) For collection properties that are not empty (have existing elements).static ExpressionIs Not Null - property is not null.static ExpressionIs Null - property is null.static ExpressionistartsWith(String propertyName, String value) Case insensitive Starts With - property like value%.static ExpressionLess Than or Equal to - property less than or equal to the given value.static ExpressionLike - property like value where the value contains the SQL wild card characters % (percentage) and _ (underscore).static ExpressionLess Than - property less than the given value.static ExpressionNot Equal To - property not equal to the given value.static Expressionnot(Expression exp) Negate the expression (prefix it with NOT).static Expressionor(Expression expOne, Expression expTwo) Or - join two expressions with a logical or.static ExpressionAdd raw expression with no parameters.static ExpressionAdd raw expression with a single parameter.static ExpressionAdd raw expression with an array of parameters.static ExpressionstartsWith(String propertyName, String value) Starts With - property like value%.
-
Method Details
-
eq
Equal To - property equal to the given value. -
ne
Not Equal To - property not equal to the given value. -
ieq
Case Insensitive Equal To - property equal to the given value (typically using a lower() function to make it case insensitive). -
inRange
In Range -property >= value1 and property < value2.Unlike Between inRange is "half open" and usually more useful for use with dates or timestamps.
-
between
Between - property between the two given values. -
between
Between - value between two given properties. -
gt
Greater Than - property greater than the given value. -
ge
Greater Than or Equal to - property greater than or equal to the given value. -
lt
Less Than - property less than the given value. -
le
Less Than or Equal to - property less than or equal to the given value. -
isNull
Is Null - property is null. -
isNotNull
Is Not Null - property is not null. -
iexampleLike
Case insensitiveexampleLike(Object) -
exampleLike
Create the query by Example expression which is case sensitive and using LikeType.RAW (you need to add you own wildcards % and _). -
exampleLike
public static ExampleExpression exampleLike(Object example, boolean caseInsensitive, LikeType likeType) Create the query by Example expression specifying more options. -
like
Like - property like value where the value contains the SQL wild card characters % (percentage) and _ (underscore). -
ilike
Case insensitive Like - property like value where the value contains the SQL wild card characters % (percentage) and _ (underscore). Typically uses a lower() function to make the expression case insensitive. -
startsWith
Starts With - property like value%. -
istartsWith
Case insensitive Starts With - property like value%. Typically uses a lower() function to make the expression case insensitive. -
endsWith
Ends With - property like %value. -
iendsWith
Case insensitive Ends With - property like %value. Typically uses a lower() function to make the expression case insensitive. -
contains
Contains - property like %value%. -
icontains
Case insensitive Contains - property like %value%. Typically uses a lower() function to make the expression case insensitive. -
isEmpty
For collection properties that are empty (have not existing elements). -
isNotEmpty
For collection properties that are not empty (have existing elements). -
in
In - property has a value in the array of values. -
in
In - using a subQuery. -
in
In - property has a value in the collection of values. -
inOrEmpty
In where null or empty values means that no predicate is added to the query.That is, only add the IN predicate if the values are not null or empty.
Without this we typically need to code an
ifblock to only add the IN predicate if the collection is not empty like:Without inOrEmpty()
query.where() // add some predicates .eq("status", Status.NEW); if (ids != null && !ids.isEmpty()) { query.where().in("customer.id", ids); } query.findList();Using inOrEmpty()
query.where() .eq("status", Status.NEW) .inOrEmpty("customer.id", ids) .findList(); -
idEq
Id Equal to - ID property is equal to the value. -
allEq
All Equal - Map containing property names and their values.Expression where all the property names in the map are equal to the corresponding value.
- Parameters:
propertyMap- a map keyed by property names.
-
raw
Add raw expression with a single parameter.The raw expression should contain a single ? at the location of the parameter.
-
raw
Add raw expression with an array of parameters.The raw expression should contain the same number of ? as there are parameters.
-
raw
Add raw expression with no parameters. -
and
And - join two expressions with a logical and. -
or
Or - join two expressions with a logical or. -
not
Negate the expression (prefix it with NOT). -
conjunction
Return a list of expressions that will be joined by AND's. -
disjunction
Return a list of expressions that will be joined by OR's.
-