I have a very useful query in JPQL:
select count(p) from Project p, in (p.members) s where s.members.email = :email
or again
select p from Project p, in (p.members) s where s.members.email = :email order by p.lastUpdate desc
It is fast, easy to understand and works flawlessly. It even works great when the relationship is no a @*ToMany but a @ElementCollection.
Now I need to convert the in (p.members) s where s.members.email = :email
to Criteria API so that I can replicate this pattern of query across many similar entities, or also add "orderBy" and other conditions programmatically and I'd rather not do it through String
manipulation, I am familiar with the basic uses of Criteria API but I am by no way an expert.
I have tried the CriteriaBuilder.in(~)
but it seems to be a totally different meaning ... or maybe I am using it wrong.
Could someone help?
I am using Hibernate 4.3.0 behind JPA 2.1 (in Play!Framework).