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

Ronald Kurz (JIRA) noreply at atlassian.com
Thu Mar 5 11:18:39 EST 2009


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

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