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 with 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 a work around for while persisting an entity.
Any help would be greatly appreciated regarding if this is a hibernate-enhance-maven-plugin bug or if there is any issue with my test?
Please find the test here
Update:
Appears to be a bug in hibernate, created the ticket, https://hibernate.atlassian.net/browse/HHH-12054