findCount

Execute a count query.

int count =

  new QCustomer()
  .name.icontains("foo.bar")
  .findCount();

Ebean will modify the query select clause as necessary executing a select count(*) type query.

select count(*)
from customer t0
where lower(t0.name) like ? escape'|'

"Many path"

When the predicates include a many path (in the example below "contacts" is a @OneToMany) then Ebean will use a subquery with count distinct.

int count =

   new QCustomer()
    .contacts.firstName.istartsWith("rob")
    .findCount();

The above query includes a many path of contacts so the SQL becomes:

select count(*)
from (
  select distinct t0.id
  from customer t0 join contact u1 on u1.customer_id = t0.id
  where lower(u1.first_name) like ? escape'|'
) as c; --bind(rob%)