[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3524) setFetchMode ignored if using createCriteria

Lindsey Carriere (JIRA) noreply at atlassian.com
Wed Sep 23 15:09:53 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34026#action_34026 ] 

Lindsey Carriere commented on HHH-3524:
---------------------------------------

@Richard, thanks for the workaround. I spent days trying to figure this out.

I have found that even using JoinFragment.INNER_JOIN doesn't work (runs N+1 queries on the collections with my openSessionInView filter enabled), yet the LEFT_OUTER_JOIN works as expected only running one query.  HQL does not have this problem at all, INNER JOIN FETCH works as expected.

See my post on the forums for full details if needed. https://forum.hibernate.org/viewtopic.php?f=1&t=999780&start=0

Have any developers confirmed this bug yet? I need a fix ASAP.

> setFetchMode ignored if using createCriteria
> --------------------------------------------
>
>                 Key: HHH-3524
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3524
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.2.5
>         Environment: Hibernate 3.2.5, Oracle 8
>            Reporter: Peter Weemeeuw
>         Attachments: test.case.tar.gz
>
>
> Hi,
> It seems that criteria.setFetchMode gets ignored if you combine it with createCriteria to add a restriction.
> This works as expected:
> DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);
> c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
> But in this case the join doesn't happen (and I get a LazyInstantiationException further on).
> DetachedCriteria c = DetachedCriteria.forClass(MenuItem.class);		
> c.setFetchMode("menuItemSubscriptions", FetchMode.JOIN);
> c.createCriteria("menuItemSubscriptions").add(
> 	Restrictions.eq("location", "B")
> );
> This does not happen if I set lazy="false" in the mappings
> file.
> Regards,
> Peter

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