/** * Add a {@link Criterion} to the HAVING clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the HAVING clause * @return this Query object, to allow chaining method calls */ public Query having(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().having(criterion); } if (this.havings == null) { this.havings = new ArrayList<>(); } this.havings.add(criterion); invalidateCompileCache(); return this; }
public void testBoundArgumentsWorkInHavingClause() { Query query = Query.select(Employee.PROPERTIES) .groupBy(Employee.MANAGER_ID) .having(Function.count(Employee.MANAGER_ID).gt(2)); SquidCursor<Employee> cursor = database.query(Employee.class, query); try { assertEquals(1, cursor.getCount()); cursor.moveToFirst(); assertEquals(bigBird.getRowId(), cursor.get(Employee.MANAGER_ID).longValue()); } finally { cursor.close(); } }
subquery.having(Function.count().gt(1));
/** * Add a {@link Criterion} to the HAVING clause of this query. Multiple calls will combine all the criterions with * AND. * * @param criterion the Criterion to add to the HAVING clause * @return this Query object, to allow chaining method calls */ public Query having(Criterion criterion) { if (criterion == null) { return this; } if (immutable) { return fork().having(criterion); } if (this.havings == null) { this.havings = new ArrayList<>(); } this.havings.add(criterion); invalidateCompileCache(); return this; }