findCount
カウントクエリを実行します。
int count =
new QCustomer()
.name.icontains("foo.bar")
.findCount();
Ebean は必要に応じてクエリの select 句
を変更して、select count(*)
タイプのクエリを実行します。
select count(*)
from customer t0
where lower(t0.name) like ? escape'|'
「多くのパス」
述語に「多くのパス」が含まれる場合(以下の例では「contacts」が @OneToMany
)、Ebean はカウントのサブクエリを使用します。
int count =
new QCustomer()
.contacts.firstName.istartsWith("rob")
.findCount();
上記のクエリには連絡先の「多くのパス」が含まれているので、SQL は以下になります。
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%)