[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-3371) Criteria Query Issue with Projection and restriction
Oliver Siegmar (JIRA)
noreply at atlassian.com
Fri Feb 27 06:15:38 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oliver Siegmar updated HHH-3371:
--------------------------------
Attachment: hibernate-projection-restriction-alias.diff
I have the same problem with Hibernate 3.3.1.GA - here's a patch (against 3.3.1.GA), that seems to fix this issue.
> 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
> 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