GROUP BY problems with Domain objects on Postgres is common to HHH-1615,
HHH-1865
,
HHH-2436
and spurred a TODO for HQL translator reworking in HHH-2407. Mostly these have to do with aggregations with GROUP BY..
HHH-1615 provides patches that will help you auto-expand a Domain object's fields into the SELECT and GROUP BY clause. Alternative non-patch query restructuring is discussed in the HHH-1615 commentary to essentially sub-select.
For non-aggregation, http://stackoverflow.com/questions/12403399/jpa2-criteria-api-creates-invalid-sql-when-using-groupby mentions that Postgres 9.2 had an improvement whereby only the primary key field was necessary in the GROUP BY (and not all other selected fields). This improvement doesn't seem to apply to aggregation however.
|