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

Uninitialized ManyToMany Entry is not removed when bytecode-enhanced Entity is deleted

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      We noticed that em.remove() of bytecode-enhanced Entity1 with an unitialized ManyToMany collection of Entity2 fails because of the database FK constraint on table Entity1_Entity2. When examining the problem, we found that the entry in the table Entity1_Entity2 was not deleted before deleting Entity1. Please find attached a test case that demonstrates the problem, here a short excerpt:

      @Entity
      public class Entity1

      { @Id private Long id; @ManyToMany private List<Entity2> entities2 = new ArrayList<>(); ... }

      In the test case, we do:

      entity1.getEntities2().add(entity2);
      ...
      em.remove(entity1);

      which fails.

      The test case starts to work if either:

      • the ManyToMany collection is initialized by calling size() before em.remove()
      • the bytecode-enhancement is switched off
      • we go back to hibernate 4.3.x

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: