I've got an entity A with a collection of B elements.
I would like to create a query that basically does this:
Select a, count(b) from A a inner join fetch a.b b group by a
I was hoping to get an Array Object where element 0 is my A entity and element 1 is a Number which is the number in the collection.
Jpa (backed by hibernate) throws the following error:
Caused by: java.sql.SQLException: Not in aggregate function or group by clause: org.hsqldb.Expression@16d829b1 in statement (sql query)
When i copy and paste the native sql from the error into postgres, it doesn't work.
When i copy and paste the native sql from the following JPQL query:
Select a, count(b) from A a inner join fetch a.b b group by a, b
Postgres returns the expected results. The problem is Hibernate still coughs up the same error as the first Query.
试试这个:
SELECT DISTINCT a, a.b.size FROM A a INNER JOIN FETCH a.b b
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.