]
Oliver Siegmar commented on HHH-3371:
-------------------------------------
I also should note, that I'm using Oracle 10g.
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: