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