entityManager
.createNativeQuery(
"SELECT " +
" p.id " +
"FROM " +
" post p " +
"WHERE EXISTS ( " +
" SELECT 1 " +
" FROM " +
" post_comment pc " +
" WHERE " +
" pc.post_id = p.id AND " +
" pc.review = 'Bingo' " +
") " +
"ORDER BY " +
" p.title " +
"OFFSET 20 ROWS " +
"FETCH NEXT 10 ROWS ONLY")
.unwrap(org.hibernate.query.Query.class)
.addQueryHint("GATHER_PLAN_STATISTICS")
.setComment("POST_WITH_BINGO_COMMENTS")
.getResultList();