[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3371) Criteria Query Issue with Projection and restriction

Gail Badner (JIRA) noreply at atlassian.com
Fri Feb 27 12:32:39 EST 2009


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

Gail Badner resolved HHH-3371.
------------------------------

      Assignee: Gail Badner
    Resolution: Duplicate

> Criteria Query Issue with Projection and restriction
> ----------------------------------------------------
>
>                 Key: HHH-3371
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3371
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.2.6
>         Environment: Hibernate version: 3.2.6ga, MySQL 5
>            Reporter: Michael Kuhinica
>            Assignee: Gail Badner
>         Attachments: hibernate-projection-restriction-alias.diff
>
>
> When I try to add a restriction to a property with a projection, hibernate generate the SQL using the property alias on the where clause instead of the property name.
> Here is an code example:
>       Criteria c = session.createCriteria(Customer.class).setProjection(
> 		Projections.projectionList()
> 			.add(Projections.property(Customer.PROP_ID), "id")
> 			.add(Projections.property(Customer.PROP_NAME), "name")
> 		)
> 		.add(Restrictions.like(Customer.PROP_EMAIL, email))
> 		.add(Restrictions.like(Customer.PROP_NAME, name));
> And the generated SQL:
>     select
>         this_.ctm_id as y0_,
>         this_.ctm_name as y1_ 
>     from
>         customers this_ 
>     where
>         this_.ctm_mail like ? 
>         and y1_ like ?
> Notice that hibernate used the right name for the customer e-mail (that has no projection on it) but it used an alias for the name that have a projection set.
> See: http://forum.hibernate.org/posting.php?mode=editpost&p=2388756 

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