Problems with @PreUpdate and flush() [message #498894] |
Wed, 18 November 2009 23:37  |
Eclipse User |
|
|
|
Hello all,
I'm trying to add auditing functionality to my entities, using an embedded entity and EntityListeners for updating the audit fields on prePersist and preUpdate.
It works except when an entity is updated and a flush is performed on the EntityManager:
- The @PreUpdate listener is invoked and changes the values
- But DatabaseQueryMechanism.updateObjectForWriteWithChangeSet() does ignore any @PreUpdate changes if it's executed within a EntityManager.flush().
Has anybody had similar problems? Is there a workaround? I'm trying to avoid committing and re-opening a new transaction.
I'm experiencing this problem in EclipseLink v1.1.2, 1.1.3 and 1.2.0.
Thanks
Thomas
|
|
|
|
|
|
Re: Problems with @PreUpdate and flush() [message #499690 is a reply to message #498894] |
Mon, 23 November 2009 13:05   |
Eclipse User |
|
|
|
In order to raise the preUpdate events, the object's changes must be computed, if you then change the object again in this event, then new changes will not be picked up (as this would require us re-computing the changes again, which would be twice as much work, but might be a useful option to have).
You can use the DescriptorEvent preUpdate instead of the JPA event, this will give you access to the DescriptorEvent object, which has an API, updateAttributeWithObject(), which will update the object, row and change set.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03826 seconds