[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-1425) Setting Projection for Criteria brake previously set Fetch mode.

Gail Badner (JIRA) noreply at atlassian.com
Thu Aug 26 12:54:43 EDT 2010


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

Gail Badner updated HHH-1425:
-----------------------------

    Affects Version/s: 3.5.5
                       3.6.0.Beta3

I am seeing this behavior in 3.5.5 and 3.6.0.Beta-3.

In trunk, it is because in org.hibernate.loader.criteria.CriteriaJoinWalker.getJoinType():

<code>
if ( translator.hasProjection() ) {
    return -1;
}
</code>

-1 indicates no join.


> Setting Projection for Criteria brake previously set Fetch mode.
> ----------------------------------------------------------------
>
>                 Key: HHH-1425
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1425
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.1.2, 3.5.5, 3.6.0.Beta3
>         Environment: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
> MySQL 4.1.9-standard
>            Reporter: Ivan Latysh
>
> A criteria query:
>   Criteria cr = session.createCriteria(ApplicationBean.class);
>   cr.setFetchMode("categories", FetchMode.JOIN);
>   cr.add(Expression.sql("category_id=?", "2", Hibernate.STRING));
>   cr.list();
> execute without an error, and produce proper sql and return expected results.
> But when I add projection right before list():
>   Criteria cr = session.createCriteria(ApplicationBean.class);
>   cr.setFetchMode("categories", FetchMode.JOIN);
>   cr.add(Expression.sql("category_id=?", "2", Hibernate.STRING));
>   cr.setProjection(Projections.count("id"));
>   cr.list();
> Query produce an SQL without a join.
> This issue has been discovered after upgrade from 3.0.5 to 3.1.2
> Mapping:
> <hibernate-mapping package="a.b">
>   <class name="ApplicationBean" table="application">
>     <id name="id" column="id" type="long">
>       <generator class="identity"/>
>     </id>
>     ...
>     <!-- Application categories  -->
>     <set name="categories" cascade="all-delete-orphan" lazy="true" table="application_category">
>       <key column="application_id"/>
>       <composite-element class="a.b.ApplicationCategory">
>         <many-to-one name="category" class="a.b.CategoryBean" column="category_id" cascade="none">
>         </many-to-one>
>       </composite-element>
>     </set>
>   </class>
> </hibernate-mapping>

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