Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Last active April 6, 2017 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thjanssen/a891b9478ed528a387e6ddfcef5af06d to your computer and use it in GitHub Desktop.
Save thjanssen/a891b9478ed528a387e6ddfcef5af06d to your computer and use it in GitHub Desktop.
Query q = em.createQuery("SELECT a, size(a.books) FROM Author a GROUP BY a.id");
List<Object[]> results = q.getResultList();
05:47:23,682 DEBUG [org.hibernate.SQL] -
select
author0_.id as col_0_0_,
count(books1_.authorId) as col_1_0_,
author0_.id as id1_0_,
author0_.firstName as firstNam2_0_,
author0_.lastName as lastName3_0_,
author0_.version as version4_0_
from
Author author0_ cross
join
BookAuthor books1_
where
author0_.id=books1_.authorId
group by
author0_.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment