I have an EntityListener that I would like to use to modify an Entity before it is persisted. The EntityListener is called and modified the entites appropriatly when I call EntityManager.persist(entity), however, when I call EntityManager.merge(entity) on an unmanaged entity, the EntityListener is called, but the changes are lost. I tracked the problem down to line 442 of MergeManager.java. It looks like builder.mergeIntoObject() prefers the original entity and overwrites the values in the "registeredObject" with the original values which blow away the changes made by the EntityListener. I assume the EntityListener behaviour would be the same for merge and persist, but it seems not. It this a bug or a feature? Do I need to do some configuration to get this to work as I expect?
[Message sent by forum member 'jonseaberg' (jonseaberg)]
http://forums.java.net/jive/thread.jspa?messageID=256415