From: Armin H. (JIRA) <no...@at...> - 2005-11-15 01:16:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=comments#action_20712 ] Armin Haaf commented on HHH-892: -------------------------------- I think this is inconsistent behaviour and therefore a bug. It is possible to alias a "standard" select column, but it is not possible to a alias a aggregate column. But there is another workaround, which should work on all environments: SELECT SUM(A.x) FROM MyClass AS A GROUP BY A.y ORDER BY SUM(A.x) This workaround may be performance relevant, because not every database is optimizing this. > HQL parser does not resolve alias in ORDER BY clause > ----------------------------------------------------- > > Key: HHH-892 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892 > Project: Hibernate3 > Type: New Feature > Versions: 3.0.5 > Environment: Hibernate 3.0.5, MySQL, Tomcat > Reporter: Guido Laures > Priority: Minor > > > When using an alias for an ORDER BY clause this is not always correctly resolved. Example: > SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY mySum > does not work because "mySum" is not resolved in the ORDER BY clause which results in an exception telling that mySum is an unknown column. > Workaround (not to say "hack") is using: > SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY col_0_0_ -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |