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

Unidirectional one-to-many doesn't take care of many side during removal if bytecode enhancement is on

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      In an unidirectional one-to-many relation, with a join column on many side, Hibernate seems to forget about nulling foreign keys when removing object on 'one' side if entities are instrumented.

      In my test-case (please see it attached) there is Garage entity keeping a set of Cars entities. During removal (without bytecode enhancement) of Garage entity, Hibernate issues the following statements:

      Hibernate:
          update
              Car
          set
              GARAGE_ID=null
          where
              GARAGE_ID=?
      Hibernate:
          delete
          from
              Garage
          where
              id=?
      

      However when entities are instrumented using 'enableLazyInitialization' mode, the first SQL statement is not generated which leads to constraint violation when the delete statement is executed.

      In order to run my test-case with bytecode enhancement (which fails), please issue the following command:

      mvn clean install -P enhancement
      

      A build run without 'enhancement' profile works correctly.

      Please note that this happens only when 'enableLazyInitialization' mode is on; other modes doesn't cause this issue.

        Attachments

          Issue links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: