[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3798) failure to lazy load a manyToOne and oneToMany mapped entity

Gail Badner (JIRA) noreply at atlassian.com
Wed Apr 21 20:28:34 EDT 2010


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

Gail Badner commented on HHH-3798:
----------------------------------

This may be related to HHH-4991.

Can you try increasing max_fetch_depth to see if that works?

> failure to lazy load a manyToOne and oneToMany mapped entity
> ------------------------------------------------------------
>
>                 Key: HHH-3798
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3798
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1, 3.5.0.Beta-1
>         Environment: hibernate annotations test case, maven profile hsqldb, svn rev 16079
> hibernate-core 3.3.1.GA, JBoss 4.2.3, SQLServer 2000
>            Reporter: Ronald Kurz
>         Attachments: test-case.tar.gz, test-case2.tar.gz
>
>
> Following situtation: an entity Data has Revision entities (oneToMany). Each Revision entity belongs to a Data entity. The Data entity has one manyToOne mapping to the current Revision. The mappings from Data to Revision are all lazy.
> When loading a Data entity, which has two Revisions, the Revision entity which is also mapped as manyToOne (the current Revision for that Data entity), does not get loaded. It will be an uninitialized proxy, which is also resistent to Hibernate.initialize(<Data>.revision). The same proxy is also in the oneToMany mapped list.
> @Entity
> public class Data {
>   @Id @GeneratedValue
>   public int id;
>   @ManyToOne(fetch = FetchType.LAZY)
>   @JoinColumn(name = "revisionId")
>   public Revision revision;
>   @OneToMany(mappedBy = "data")
>   public List<Revision> revisions = new ArrayList<Revision>();
> }
> @Entity
> public class Revision {
>   @Id @GeneratedValue
>   public int id;
>   @ManyToOne(fetch = FetchType.LAZY)
>   @JoinColumn(name = "dataId", nullable = false, updatable = false)
>   public Data    data;
>   public Integer number;
> }
> The test case is written for the hibernate-annotations project (simply because I never wrote a mapping using xml)

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