I use Hibernate as persistence provider, database is Oracle XE. Here is a JP QL query:
SELECT news, COUNT(comments)
FROM News news JOIN news.comments comments
GROUP BY news
News
is in one-to-many relation with Comments
.
When i try to use it, the following error appears:
ERROR SqlExceptionHelper:146 - ORA-00979: not a GROUP BY expression
But in Pro JPA 2, 2nd edition (page 222) I found almost the same query:
SELECT e, COUNT(p)
FROM Employee e JOIN e.phones p
GROUP BY e
What's wrong with the former one?