I'm having trouble figuring out how to represent the following JPQL query:
SELECT count(e) FROM Foo e
using Criteria API. What I'm trying is:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Foo> c = cb.createQuery(Foo.class);
Root<Foo> f = c.from(Foo.class);
c.select(cb.count(f));
but this is not working. I also tried:
c.select(cb.count(f.get("id"));
This is for JPA2, Eclipselink.