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 Junctionstatic Junctionstatic SubQueryAverages the numeric field at the end ofpath, which has to contain at least one relation (e.g.static ConditioncommaSeparatedListContains(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 SubQueryCounts the entities of the relation at the end ofpath(e.g.static Conditionequation(Factor left, EquationNode.Operator op, Factor right) equations(Factor left, EquationNode.Operator op, Iterable<? extends Factor> right) Creates as many equation conditions asrightfactors are specified.static SubQueryCreates a newEXISTSsubquery to the given path.static SubQueryexistsNested(String path) If `path` involves multiple paths (like relFoo.relBar), create nested exists.static FieldDefCreates a newfield defintionthat can be used to create conditions starting from a field.static FieldDeffieldExists(String name) Same asfield(String)but uses (nested) exists statements.static Functionstatic Functionstatic ConditionisFalse()static ConditionisTrue()static Functionstatic Functionstatic Factorstatic SubQueryThe maximum of the comparable field at the end ofpath, which has to contain at least one relation (e.g.static SubQueryThe minimum of the comparable field at the end ofpath, which has to contain at least one relation (e.g.static Junctionstatic Junctionstatic Junctionstatic Junctionstatic Factorstatic Factorstatic ConditionprimaryKeyIn(Iterable<PrimaryKey> keys) static ConditionprimaryKeyIs(PrimaryKey key) static Conditionstatic Conditionstatic RelationDefCreates a newrelation definitionthat can be used to create conditions starting from a relation.static ConditionrelationTo(String relationPath, PrimaryKey key) Creates a condition that checks whether the givenrelationPathpoints to the entity specified bykey.static ConditionrelationToAll(String relationPath, Iterable<PrimaryKey> keys) Creates a condition that checks whether the givenrelationPathpoints to all entities given bykeys.static ConditionrelationToOne(String relationPath, Iterable<PrimaryKey> keys) Creates a condition that checks whether the givenrelationPathpoints to at least one of the entities specified bykeys.static UncorrelatedSubQuerysubSelect(String column, EntityModel model) Create an uncorrelated sub select that may select a column from an the provided entity model.static SubQuerySums the numeric field at the end ofpath, which has to contain at least one relation (e.g.
-
Method Details
-
equation
-
equations
-
and
-
and
-
or
-
or
-
not
-
not
-
function
-
fulltext
-
likeall
-
likeall
-
count
Counts the entities of the relation at the end ofpath(e.g.relRegistration). The relations before the last one are joined in the main query, so the count is calculated per entity reached by them: onEvent_status,count("relEvent.relRegistration").is(3)matches if one event has 3 registrations, not if all events together have 3. -
sum
Sums the numeric field at the end ofpath, which has to contain at least one relation (e.g.relOrder_position.price_order_currency). Likecount, a sum over no rows is 0. The relations before the last one are joined in the main query, so the sum is calculated per entity reached by them: onOrder_status,sum("relOrder.relOrder_position.price_order_currency").is(100)matches if the positions of one order sum up to 100, not if the positions of all orders together do. -
avg
Averages the numeric field at the end ofpath, which has to contain at least one relation (e.g.relOrder_position.price_order_currency). An average over no rows is null and therefore only matchesis(null). The relations before the last one are joined in the main query, so the average is calculated per entity reached by them, not over all entities at the end of the path. -
min
The minimum of the comparable field at the end ofpath, which has to contain at least one relation (e.g.relReservation.date_from). The minimum over no rows is null and therefore only matchesis(null). The relations before the last one are joined in the main query, so the minimum is calculated per entity reached by them, not over all entities at the end of the path. -
max
The maximum of the comparable field at the end ofpath, which has to contain at least one relation (e.g.relReservation.date_from). The maximum over no rows is null and therefore only matchesis(null). The relations before the last one are joined in the main query, so the maximum is calculated per entity reached by them, not over all entities at the end of the path. -
exists
-
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 specialSubQueryclass 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
UncorrelatedSubQueryinstance
-
relationTo
Creates a condition that checks whether the givenrelationPathpoints to the entity specified bykey. -
relationToOne
Creates a condition that checks whether the givenrelationPathpoints to at least one of the entities specified bykeys. -
relationToAll
Creates a condition that checks whether the givenrelationPathpoints to all entities given bykeys. -
field
-
fieldExists
Same asfield(String)but uses (nested) exists statements. -
relation
Creates a newrelation definitionthat 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
-