Sun Java System Application Server Platform Edition 9 Release Notes

A query grouping by a JOIN variable and directly selecting the JOIN variable might result in a SQLException

A query grouping by a JOIN variable and directly selecting the JOIN variable might result in a SQLException complaining about non-grouping expressions being selected. For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=197. For example:


SELECT AVG(o.totalPrice), c FROM Order o JOIN o.customer c GROUP BY c

Solution

A possible workaround is to directly navigate the relationship instead of defining a JOIN variable; for example:


SELECT AVG(o.totalPrice), o.customer FROM Order GROUP BY o.customer