Group by on alias doesn't replace alias
When you group by on an alias, Hibernate doesn't use the column alias in the group by statement. It is best explained with the following example
The resulting SQL
Notice how in the SQL the group by statement still uses the "usr" alias defined in the HQL in stead of col_0_0_.
I think this would be a nice addition for dialects that do support it. I just stumbled upon a use case where I want to group by a function that takes a parameter, and when the same fragment is reused in the group by clause (the usual workaround) it is not detected as the same fragment and the query will fail. Is there any way we could support this, even though it would be against the spec? Possibily enabled through a config property?
Closing rejected issues.
Some DBs support it, but it is not ANSI SQL.
Ok, strange. In straight SQL it works fine.