Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-3332

Hibernate duplicate then child entity's on merge

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.2.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JDK 1.6
      Oracle 9i
      Hibernate 3.2.6
      Hibernate Annotations 3.3.1
      Hibernate EntityManager 3.3.2
      Standalone Running
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      The method merge from EntityManager causes a duplication of child entity's.

      class Father:
      @OneToMany(mappedBy = "father", cascade=

      {CascadeType.ALL}

      , fetch=FetchType.LAZY)
      private List<Child> childList;

      class Child:
      @ManyToOne @JoinColumn(name = "ID_FATHER")
      private Father father;

      class BugTest
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("JpaTestHB");
      EntityManager em = emf.createEntityManager();

      Father f = (Father) em.createQuery("SELECT f FROM Father f WHERE f.id = 1").getSingleResult();

      Child c = new Child();
      c.setFather(f);
      f.getChildList().add(c);

      em.getTransaction().begin();
      em.merge(f);
      em.getTransaction().commit();

      The execution of BugTest Class causes tow insert's on table "child".
      If you change the fetch mode to EAGER (into Father class) the problem not occurs.

      I make the same test with Toplink, and it make a unique insert, normal.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            mressler Mike Ressler added a comment -

            I just downloaded hibernate-3.5.5-Final to see if this was resolved The issue still exists for me. Anyone else following this bug having similar problems? I'll try to come up with a failing test case for this issue.

            Show
            mressler Mike Ressler added a comment - I just downloaded hibernate-3.5.5-Final to see if this was resolved The issue still exists for me. Anyone else following this bug having similar problems? I'll try to come up with a failing test case for this issue.
            Hide
            gbadner Gail Badner added a comment -

            Mike, if you come up with a testcase that reproduces this, please open a new JIRA issue.

            Show
            gbadner Gail Badner added a comment - Mike, if you come up with a testcase that reproduces this, please open a new JIRA issue.
            Hide
            specialseth Seth Martin added a comment -

            This problem still persists into 3.6.0. HHH-5855

            Show
            specialseth Seth Martin added a comment - This problem still persists into 3.6.0. HHH-5855
            Hide
            steve Steve Ebersole added a comment -

            Bulk closing stale resolved issues

            Show
            steve Steve Ebersole added a comment - Bulk closing stale resolved issues
            Hide
            Kovacik Martin added a comment -

            I'm on 4.2.3.Final and this issue is still there

            Show
            Kovacik Martin added a comment - I'm on 4.2.3.Final and this issue is still there

              People

              • Votes:
                10 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development