According to the website, I'm supposed to post here for bugs first. So be it.
So here goes. Using the following JPA 2.0 Query constructor, I want to do the equivalent to:
"select count(u) from User u;"
I've confirmed with Linda, the JPA 2.0 spec person at Sun that the code for that should look like this:
public void CountUsers(EntityManager em) {
CriteriaBuilder cb= em.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<User> u = cq.from(User.class); cq.select(cb.count(u)); }
Internally, Hibernate generates this string select count() from com.example.User as generatedAlias0 but then kvetches about the ) as an org.hibernate.hql.ast.QuerySyntaxException.
Pierce
|