So this is an example with 'inner' AND/conjunctions .... wrapped in a OR/disjunction.
So again for people reading this:
disjunction = a list of expressions added together with OR
conjunction = a list of expressions added together with AND
public void test() {
ResetBasicData.reset();
java.sql.Date onAfter = java.sql.Date.valueOf("2009-08-31");
Query<Customer> q = Ebean.find(Customer.class)
.setUseIndex(UseIndex.NO)
.where()
.disjunction()
.conjunction()
.startsWith("name", "r")
.eq("anniversary", onAfter)
.endJunction()
.conjunction()
.eq("status", Customer.Status.ACTIVE)
.gt("id", 0)
.endJunction()
.orderBy().asc("name");
List<Customer> customers = q.findList();
String sql = q.getGeneratedSql();
...
}
Results in:
<sql summary='Customer' >
select
c.id c0, c.status c1,
c.name c2, c.smallnote c3, c.anniversary c4, c.cretime c5, c.updtime c6, c.billing_address_id c7, c.shipping_address_id c8
from o_customer c
where ((
c.name like ? and c.anniversary = ? ) or (c.status = ? and
c.id > ? ) )
order by
c.name</sql>
Cheers, Rob.