Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Issues List »

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

Anupam M (JIRA)

2008-07-02

Replies: Find Java Web Hosting

Author LoginPost Reply

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

Michael Kuhinica commented on HHH-3371:
---------------------------------------

Sorry the link was wrong. See this one instead: http://forum.hibernate.org/viewtopic.php?t=988049

> Criteria Query Issue with Projection and restriction
> ----------------------------------------------------
>
>           Key: HHH-3371
>           URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3371
>         Project: Hibernate3
>       Issue Type: Bug
>       Components: query-criteria
>   Affects Versions: 3.2.6
>      Environment: Hibernate version: 3.2.6ga, MySQL 5
>        Reporter: Michael Kuhinica
>
> 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

   
_______________________________________________
hibernate-issues mailing list
hibernate-issues@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-issues
©2008 gg3721.com - Jax Systems, LLC, U.S.A.