public void testHavingConstraintSet() throws Exception { q1 = new Query("select table1.field1 from table1 group by table1.field1 having (table1.field1 = table1.field2 or table1.field1 = table1.field3)"); q2 = new Query(); Table t1 = new Table("table1"); Field f1 = new Field("field1", t1); Field f2 = new Field("field2", t1); Field f3 = new Field("field3", t1); SelectValue sv1 = new SelectValue(f1, null); q2.addSelect(sv1); q2.addFrom(t1); q2.addGroupBy(f1); ConstraintSet cs1 = new ConstraintSet(); cs1.add(new Constraint(f1, Constraint.EQ, f2)); cs1.add(new Constraint(f1, Constraint.EQ, f3)); q2.addHaving(cs1); assertEquals(q2, q1); }
Read more here: Source link