[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3949) Intrumentated to one relations can not be join fetched

Don Goertzen (JIRA) noreply at atlassian.com
Tue Jun 30 15:08:15 EDT 2009


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

Don Goertzen commented on HHH-3949:
-----------------------------------

We're experiencing the same issue (ours is a ManyToOne/LazyToOne).  It seems the join-fetched entity does get loaded on the session, but the association does not initialize (remains null) until that associated entity is accessed.  When the associated entity is accessed, an additional select is issued to retrieve the foreign id and the association is then initialized to the loaded entity without re-selecting it.

Impact: when the owner entity is passed out of the session, LazyInitializationExceptions occur when trying to access the associated entity, even though we had join-fetched it.  

A workaround is to force initialization of the associations programmatically by accessing the associated entity in each relation before returning the owner entity.  This results in (n) additional, unnecessary selects and makes for some ugly data access manager code.

> Intrumentated to one relations can not be join fetched
> ------------------------------------------------------
>
>                 Key: HHH-3949
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3949
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core, query-criteria, query-hql
>    Affects Versions: 3.3.1
>            Reporter: Gérald Quintana
>         Attachments: hhh-3949.tar.bz2
>
>
> 1) Relation Person -> Vehicle is annotated
>     @OneToOne(optional=true, mappedBy="driver", fetch=FetchType.LAZY)
>     @LazyToOne(LazyToOneOption.NO_PROXY)
>     private Vehicle vehicle;
> 2) Both entities are instrumented with Javassist
> 3) Query (HQL or Criteria) Person and Vehicle: from Person p left join fetch p.vehicle
> => SQL query is correct but Vehicles are not loaded

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