Issue Type: Bug Bug
Affects Versions: 4.2.0.Final
Assignee: Brett Meyer
Created: 16/Apr/13 7:39 AM
Description:

We have a few test failures on Postgres Plus 9.2 due to a ambiguous column reference, in these tests:
org.hibernate.test.hql.FunctionNameAsColumnTest.testGetMultiColumnSameNameAsArgFunctionCriteria
org.hibernate.test.hql.FunctionNameAsColumnTest.testGetMultiColumnSameNameAsArgFunctionHQL
org.hibernate.test.hql.FunctionNameAsColumnTest.testGetMultiColumnSameNameAsNoArgFunctionCriteria
org.hibernate.test.hql.FunctionNameAsColumnTest.testGetMultiColumnSameNameAsNoArgFunctionHQL

org.hibernate.test.hql.FunctionNameAsColumnTest.testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL

Eg. testGetMultiColumnSameNameAsArgFunctionCriteria:

Stacktrace

org.hibernate.exception.SQLGrammarException: could not extract ResultSet
...
Caused by: com.edb.util.PSQLException: ERROR: column reference "lower" is ambiguous
  Position: 858

the problem is in the generated query:

select this_.ID as ID1_1_3_, this_.nextHolder as nextHold2_1_3_, entitywith2_.ID as ID1_1_0_, entitywith2_.nextHolder as nextHold2_1_0_, entitywith3_.HOLDER_ID as HOLDER4_1_5_, entitywith3_.ID as ID1_0_5_, entitywith3_.ID as ID1_0_1_, entitywith3_.lower as lower2_0_1_, entitywith3_.upper as upper3_0_1_, entitywith4_.HOLDER_ID as HOLDER4_1_6_, entitywith4_.ID as ID1_0_6_, entitywith4_.ID as ID1_0_2_, entitywith4_.lower as lower2_0_2_, entitywith4_.upper as upper3_0_2_ from ENTITY_WITH_FN_AS_COL_HOLDER this_ left outer join ENTITY_WITH_FN_AS_COL_HOLDER entitywith2_ on this_.nextHolder=entitywith2_.ID left outer join ENTITY_WITH_ARG_FN_AS_COL entitywith3_ on entitywith2_.ID=entitywith3_.HOLDER_ID left outer join ENTITY_WITH_ARG_FN_AS_COL entitywith4_ on this_.ID=entitywith4_.HOLDER_ID where this_.nextHolder is not null order by entitywith3_.lower, lower(entitywith3_.upper), entitywith4_.lower, lower(entitywith4_.upper)

there is also comparison failure in testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL, which I belive is caused by the same problem

org.junit.ComparisonFailure: expected:<[yadda yadda yadda]> but was:<[blah blah blah]>
Project: Hibernate ORM
Priority: Major Major
Reporter: Zbyněk Roubalík
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira