QueryFactory qf = getQueryFactory();
//test for parenthesis, "and" should have higher priority
Query q = qf.from(getModelFactory().getUserImplClass())
.having("name").eq("Spider")
.or(qf.having("name").eq("John"))
.and(qf.having("surname").eq("Man"))
.toBuilder().build();
List<User> list = q.list();
assertEquals(2, list.size());