[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-892) HQL parser does not resolve alias in ORDER BY clause

Gail Badner (JIRA) noreply at atlassian.com
Mon Sep 20 14:46:25 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38459#action_38459 ] 

Gail Badner commented on HHH-892:
---------------------------------

I just checked a fix for this issue into trunk. It would be great if some folks could give it a try to see if it works.

I've included a new method, Dialect.replaceResultVariableInOrderByClauseWithPosition() (yes, I know it's kinda long), to indicate that a select expression position should be used instead of the "result variable". A "result variable" corresponds to the alias(es) assigned to an HQL select expression.

By default, false is reeturned. Dialects that require the position should override this method.

I don't know of any dialects that need to override this method. I'll check the test results for the dialects we test, and make any necessary corrections tomorrow. I'll need input from others about dialects we do not regularly use for testing.

Thanks,
Gail

> HQL parser does not resolve alias in ORDER  BY clause
> -----------------------------------------------------
>
>                 Key: HHH-892
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-hql
>    Affects Versions: 3.5.4, 3.6.0.Beta1
>         Environment: Hibernate 3.0.5, MySQL, Tomcat
>            Reporter: Guido Laures
>            Assignee: Gail Badner
>             Fix For: 3.6.x
>
>         Attachments: HHH-892.patch, HibernateHavingAliasTest.java
>
>
> 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

        


More information about the hibernate-issues mailing list