openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wlad <>
Subject Re: JPA Criteria API query - sorting by number of elements in collection
Date Thu, 09 Jan 2014 11:05:54 GMT
Yes, it does work, but with that query I am getting that extra data in result
- number of comments. And I need to get result in a form of list of Post
objects (List<Post>).

In the meantime I have found a way to build this query using JPA Criteria

	CriteriaBuilder cb = em.getCriteriaBuilder();
        CriteriaQuery<Post> cq = cb.createQuery(Post.class);
        Root<Post> p = cq.from(Post.class);;
        Query q = em.createQuery(cq);
        List<Post> resultList = (List<Post>) q.getResultList();

Anyway, thanks for reply.

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message