Class Conditions
java.lang.Object
ch.tocco.nice2.persist.core.api.qb2.Conditions
This is a hub-class that defines some nice-to-have shortcuts but also collects
static methods from other places. The idea is to have a single import line to
access the query builder "dsl".
-
Method Summary
Modifier and TypeMethodDescriptionstatic Junction
static Junction
static Condition
commaSeparatedListContains
(String fieldName, String string, boolean orEmpty) Condition that checks whether the provided `string` is contained (exact match!) in a comma separated list to be found in field `fieldName`.static SubQuery
static Condition
equation
(Factor left, EquationNode.Operator op, Factor right) equations
(Factor left, EquationNode.Operator op, Iterable<? extends Factor> right) Creates as many equation conditions asright
factors are specified.static SubQuery
Creates a newEXISTS
subquery to the given path.static SubQuery
existsNested
(String path) If `path` involves multiple paths (like relFoo.relBar), create nested exists.static FieldDef
Creates a newfield defintion
that can be used to create conditions starting from a field.static FieldDef
fieldExists
(String name) Same asfield(String)
but uses (nested) exists statements.static Function
static Condition
isFalse()
static Condition
isTrue()
static Function
static Function
static Factor
static Junction
static Junction
static Junction
static Junction
static Factor
static Factor
static Condition
primaryKeyIn
(Iterable<PrimaryKey> keys) static Condition
primaryKeyIs
(PrimaryKey key) static Condition
static Condition
static RelationDef
Creates a newrelation definition
that can be used to create conditions starting from a relation.static Condition
relationTo
(String relationPath, PrimaryKey key) Creates a condition that checks whether the givenrelationPath
points to the entity specified bykey
.static Condition
relationToAll
(String relationPath, Iterable<PrimaryKey> keys) Creates a condition that checks whether the givenrelationPath
points to all entities given bykeys
.static Condition
relationToOne
(String relationPath, Iterable<PrimaryKey> keys) Creates a condition that checks whether the givenrelationPath
points to at least one of the entities specified bykeys
.static UncorrelatedSubQuery
subSelect
(String column, EntityModel model) Create an uncorrelated sub select that may select a column from an the provided entity model.
-
Method Details
-
equation
-
equations
public static Iterable<Condition> equations(Factor left, EquationNode.Operator op, Iterable<? extends Factor> right) Creates as many equation conditions asright
factors are specified. -
and
-
and
-
or
-
or
-
not
-
not
-
function
-
likeall
-
likeall
-
count
-
exists
Creates a newEXISTS
subquery to the given path. -
existsNested
If `path` involves multiple paths (like relFoo.relBar), create nested exists. Otherwise it is the same asSubQuery.exists(String)
. Example: instead of `exists(relFoo.relBar where …` do `exists(relFoo where exists(relBar where –))` A specialSubQuery
class is returned, where each condition that is added via `where` calls is appended to the innermost subquery. Calls to `isTrue` apply to all subqueries. All other (reading) operations are applied to the root subquery. -
subSelect
Create an uncorrelated sub select that may select a column from an the provided entity model. E.g.EntityModel userModel = context.getEntityManager("User").getModel(); EntityList foundUsers = queryBuilder.find("User").where( field("birthdate").greaterThan(subSelect("birthdate", userModel).where( field("lastname").is("Ott") )), field("firstname").is("Robin") ).build(context).execute());
- Parameters:
column
- the column to selectmodel
- the target entity model- Returns:
- the
UncorrelatedSubQuery
instance
-
relationTo
Creates a condition that checks whether the givenrelationPath
points to the entity specified bykey
. -
relationToOne
Creates a condition that checks whether the givenrelationPath
points to at least one of the entities specified bykeys
. -
relationToAll
Creates a condition that checks whether the givenrelationPath
points to all entities given bykeys
. -
field
Creates a newfield defintion
that can be used to create conditions starting from a field. -
fieldExists
Same asfield(String)
but uses (nested) exists statements. -
relation
Creates a newrelation definition
that can be used to create conditions starting from a relation. -
param
-
literal
-
path
-
-
primaryKeyIn
-
primaryKeyIsNot
-
commaSeparatedListContains
public static Condition commaSeparatedListContains(String fieldName, String string, boolean orEmpty) Condition that checks whether the provided `string` is contained (exact match!) in a comma separated list to be found in field `fieldName`.- Parameters:
fieldName
- the name of the field containing the comma separated list on the entitystring
- a string to be found in the listorEmpty
- set to `true` to also return entities if the field `fieldName` is empty- Returns:
- a `Condition`
-
isFalse
-
isTrue
-
raw
-