[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=co...
]
Gail Badner commented on HHH-892:
---------------------------------
There is a problem with the patch. If there is an alias that has the same name as a
column, the column takes precedence.
This will happen, even if the column has a different alias.
For example, an HQL query like:
"select z.address as name, z.name as address from Zoo z order by name,
address"
is resolving to:
<code>
select
zoo0_.street as col_0_0_,
zoo0_.city as col_0_1_,
zoo0_.postalCode as col_0_2_,
zoo0_.country as col_0_3_,
zoo0_.state_prov_id as col_0_4_,
zoo0_.name as col_1_0_
from
Zoo zoo0_
order by
zoo0_.name,
zoo0_.street,
zoo0_.city,
zoo0_.postalCode,
zoo0_.country,
zoo0_.state_prov_id
</code>
It should resolve to:
<code>
select
zoo0_.street as col_0_0_,
zoo0_.city as col_0_1_,
zoo0_.postalCode as col_0_2_,
zoo0_.country as col_0_3_,
zoo0_.state_prov_id as col_0_4_,
zoo0_.name as col_1_0_
from
Zoo zoo0_
order by
col_0_0_,
col_0_1_,
col_0_2_,
col_0_3_,
col_0_4_,
col_1_0_
</code>
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.0.CR1
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira