[hibernate-issues] [Hibernate-JIRA] Reopened: (HHH-5063) Projections that have aliases same as the property name result in invalid sql

Steve Ebersole (JIRA) noreply at atlassian.com
Tue May 11 11:16:24 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5063?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole reopened HHH-5063:
---------------------------------


Hudson shows this either not fixed or causing a regression.  Also, no fix-for version was specified...

> Projections that have aliases same as the property name result in invalid sql
> -----------------------------------------------------------------------------
>
>                 Key: HHH-5063
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5063
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.5.0-Final
>            Reporter: Shawn Clowater
>            Assignee: Gail Badner
>         Attachments: HHH-5063-testcase.patch
>
>
> I have a criteria query that is using an AliasToBeanTransformer that I'm using to selectively populate some of the properties.  It appears that the transformer requires the alias values to match the properties of your bean so that it can call the setters via reflection.
> The code snippet is similar to the following
> return (List<DataProvider>) session.createCriteria(DataProvider.class)
>                 .setProjection(Projections.projectionList()
>                         .add(Projections.property("dataProviderId), "dataProviderId")
>                         .add(Projections.property("uuid"), "uuid")
>                         .add(Projections.property("name"), "name")
>                         .add(Projections.property("dataProviderGroup"), "dataProviderGroup")
>                         .add(Projections.property("verifiedFlg"), "verifiedFlg")
>                 )
>                 .setResultTransformer(new AliasToBeanResultTransformer(DataProvider.class))
>                 .addOrder(Order.asc("name"))
>                 .list();
> And is resulting in the following SQL
> select y0_ as y0_, y1_ as y1_, y2_ as y2_, y3_ as y3_, y4_ as y4_ from DATA_PROVIDER this_ order by y2_ asc
> I can assure you that my column names are not y0_, etc.
> This worked in 3.3.2 and I am suspecting it might be due to the change for HHH-1088.  If I don't specify the alias or even change the value then it will produce a valid query it just won't populate by bean correctly.
> i.e. if I append anything to the end of the first alias (i.e. "hi") results in:
> select this_.DATA_PROVIDER_ID as y0_, y1_ as y1_, y2_ as y2_, y3_ as y3_, y4_ as y4_ from DATA_PROVIDER this_ order by y2_ asc

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