[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2390) select clause alias in HQL is mapped incosistently in SQL.

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Mon Jan 29 09:50:21 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2390?page=comments#action_25948 ] 

Max Rydahl Andersen commented on HHH-2390:
------------------------------------------

more details at http://forum.hibernate.org/viewtopic.php?p=2339064 about possible cause.

> select clause alias in HQL is mapped incosistently in SQL.
> ----------------------------------------------------------
>
>          Key: HHH-2390
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2390
>      Project: Hibernate3
>         Type: Bug

>   Components: query-hql
>     Versions: 3.2.2
>  Environment: Win2K+JDK1.5+Eclipse3.2.1+Hibernate3.2.2,  Solaris Express x86+MySQL5
>     Reporter: Natto Lover
>  Attachments: HQLTest.zip
>
>
> Hi.  I was told at the users forum to post a test case here.
> I give an alias to an expression in the select clause, try to refer it in the where clause. In SQL, Hibernate replaces the alias in the select clause, but leaves the original text in the where clause. 
> This is the HQL:
> select (p.endDate - p.startDate) as period, p 
> from Project as p 
> where period > :period_length 
> See above where the alias 'period' appears. 
> Now, This is the resulting SQL: select 
>  project0_.end_date-project0_.start_date as col_0_0_, 
>  project0_.id as col_1_0_, 
>  project0_.id as id0_, 
>  project0_.name as name0_, 
>  project0_.start_date as start3_0_, 
>  project0_.end_date as end4_0_ 
> from PROJECT project0_ where period>? 
> Note above the 'period' that was in the select clause is replaced with machine generated "col_0_0_", but that is not applied for the alias in the where clause. 
> Please find attached a test case archive.
> Two HQL statements are tried.  One uses the alias in the where clause, the other one uses the alias in the order by clause.

-- 
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