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

'Detached entity passed to persist' during merge when enableLazyInitialization is set to true

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      After migrating hibernate from 4.3.11 to 5.1.10 and using the new hibernate-enhance-maven-plugin replacing the deprecated ant bytecode enhancement task, the following happens with an entity with OneToMany association and CascadeType.ALL.

      • enableLazyInitialization set to false and the test passes
      • enableLazyInitialization set to true and the test fails with "Detached entity passed to persist"

      App worked fine with 4.3.11 version of hibernate and the old bytecode enhancement with ant task.

      I can work around this by removing CascadeType.PERSIST but needs to modify lot of associations and the related service classes for persisting new entity.

      From the debugging, I found that a Persist event triggers followed by Merge event when CascadeType.ALL is set on an association and the entities are detached when enableLazyInitialization is set to true.

      Please find the test attached.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: