[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6405) setFetchMode ignored in certain cases when using criteria queries

David Mansfield (JIRA) noreply at atlassian.com
Wed Jul 6 16:17:53 EDT 2011


setFetchMode ignored in certain cases when using criteria queries
-----------------------------------------------------------------

                 Key: HHH-6405
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6405
             Project: Hibernate Core
          Issue Type: Bug
    Affects Versions: 4.0.0.Beta2, 3.6.5
            Reporter: David Mansfield


Description:

Setting join type (e.g.) criteria.setJoinType("association.path", FetchType.JOIN) is ignored if the association being set is one of a few types.  I believe many-to-many, and any association off of a collection-of-component.  For these types of associations, the specified fetch type is ignored.

This worked in prior versions.

This has nothing to do with having additional restrictions on the same association, which is a different issue altogether.

Technical analysis:

This regression was introduced in git commit fbae6db0abaeb6f050ee97ce53d09d74886a7e47, and the fix for a possibly related issue in git commit 1c556dc775708706b6ca84251cb170d3c46f729f was not a complete fix, or rather did not fix this case scenario.

The first referenced commit split the JoinWalker.getJoinType(...) api into two methods, one with more parameters.  In the base class implementation, one method or the other is called based on the type of association (see above).  However, in the CriteriaJoinWalker (a subclass), the existing implementation only overrode one of these two methods, (the one with more arguments) causing calls into the other method to be handled by the base class, which did not function appropriately.

The second referenced commit introduced an override for the second method, however the implementation was incomplete, and was missing the crucial piece, specifically:

FetchMode fetchMode = translator.getRootCriteria().getFetchMode( path.getFullPath() );

which examined the explicitly set join types in the translator.

A fix will be supplied on github for 3.6.x and 4.0.

The implementation re-unifies the two methods in the CriteriaJoinWalker, using if/else to delegate to the correct super.getJoinType(...) method as appropriate.




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