Hi Gordon, hi Tom,
could somebody please review my fix for issue 2894: merge does not
trigger prepersist callbacks
https://glassfish.dev.java.net/issues/show_bug.cgi?id=2894
Changes for issue 2894:
entity-persistence/src/java/oracle/toplink/essentials/internal/sessions/UnitOfWorkImpl.java:
- prePersist events are now called, when new instance and back up copy
are registered in UoW
- removed unused import
- cloneAndRegisterNewObject, registerNewObjectClone:
- pass ClassDescriptor to UoW.registerNewObjectClone
- registerNotRegisteredNewObjectForPersist:
- removed prePersist callback code
- pass ClassDescriptor to UoW.registerNewObjectClone
- registerNewObjectClone:
- added prePersist callback code
- prePersist callbacks are triggered only, if clone registered for the
first time
- needed ClassDescriptor for callback check. Descriptor is available
in every calling method and passed in
entity-persistence/src/java/oracle/toplink/essentials/internal/ejb/cmp3/base/RepeatableWriteUnitOfWork.java:
- registerNotRegisteredNewObjectForPersist:
- pass ClassDescriptor to UoW.registerNewObjectClone
entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/cmp3/advanced/CallbackEventJUnitTestSuite.java:
- testMergeCascadesPersist:
- added, an un-managed Project newProj is added to managed Employee
emp, them em.merge(emp) is called
- prePersist callback needs to be tested on managed copy of newProj:
managedProj
The check in UoW.registerNewObjectClone should ensure that prePersist
callbacks are only called once per EntityManager/Transaction/instance.
What do you think?
Thanks!
-- markus.