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

errorken (JIRA) noreply at atlassian.com
Sun Dec 13 08:29:09 EST 2009


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

errorken commented on HHH-3524:
-------------------------------

I'm seeing the exact same problems as described here.

If I create a Criteria which executes two joins (one  inner join and one outer join) on two set collection then both are eagerly fetched automatically.
This is in contradiction with the HQL equivalent, where an explicit 'fetch' is required to do this.

Futher more, setting the fetch type to SELECT (either on the root criteria or sub criteria if you are using them) doens't work.
I was trying to trigger the LazyInitializatoinExcepion by setting the fetch type to SELECT and then hitting the collection after TX end.
When I replaced the criteria code with HQL: it goes as expected, I get the LazyInitException when I remove on of the two "fetch" keywords in the query.

The setFetchMode in combination with the Criteria API the fetch type seems to be completely fubar.
Also; the setFetchType does not throws errors when the association path does not exist, it just takes any string and it never does a thing.

Thanks 

> 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