Currenlty, when grouping or ordering by a selected entity valued path we must expand the expression to all the entity type’s columns to make sure we match what we do for selections. For example this query select a from EntityA a group by a would be translated as:
select a.id, a.name, a.another_col
from EntityA a
group by a.id, a.name, a.another_col
Some databases support functional dependency for ordering and grouping, which would allow us to only use the primary key of the table in group by and order by clauses, reducing the length of the query and possibly avoiding some edge-case problems. This JOOQ article lists some database Dialects which should support this functionality. |