PUBLIC: Returns an expression equivalent to none of
attributeName
holding true for
criteria
.
For every expression with an anyOf, its negation has either an allOf or a
noneOf. The following two examples will illustrate as the second is the
negation of the first:
AnyOf Example: Employees with a '613' area code phone number.
ReadAllQuery query = new ReadAllQuery(Employee.class);
ExpressionBuilder employee = new ExpressionBuilder();
Expression exp = employee.anyOf("phoneNumbers").get("areaCode").equal("613");
NoneOf Example: Employees with no '613' area code phone numbers.
ExpressionBuilder employee = new ExpressionBuilder();
ExpressionBuilder phones = new ExpressionBuilder();
Expression exp = employee.noneOf("phoneNumbers", phones.get("areaCode").equal("613"));
SQL:
SELECT ... EMPLOYEE t0 WHERE NOT EXISTS (SELECT ... PHONE t1 WHERE
(t0.EMP_ID = t1.EMP_ID) AND (t1.AREACODE = '613'))
noneOf is the universal counterpart to the existential anyOf. To have the
condition evaluated for each instance it must be put inside of a subquery,
which can be expressed as not exists (any of attributeName some condition).
(All x such that !y = !Exist x such that y).
Likewise the syntax employee.noneOf("phoneNumbers").get("areaCode").equal("613")
is not supported for the equal
must go inside a subQuery.
This method saves you from writing the sub query yourself. The above is
equivalent to the following expression:
ExpressionBuilder employee = new ExpressionBuilder();
ExpressionBuilder phone = new ExpressionBuilder();
ReportQuery subQuery = new ReportQuery(Phone.class, phone);
subQuery.retreivePrimaryKeys();
subQuery.setSelectionCriteria(phone.equal(employee.anyOf("phoneNumbers").and(
phone.get("areaCode").equal("613")));
Expression exp = employee.notExists(subQuery);