The JPA specification does not offer a solution to this, but EclipseLink has extended support for SessionEvents and UnitOfWorkChangeSets.
Refer to the SessionEventListener and SessionEventManager, which can be configured using a SessionCustomizer in your persistence.xml,
http://www.eclipse.org/eclipselink/api/1.2/org/eclipse/persistence/sessions/SessionEventListener.htmlhttp://www.eclipse.org/eclipselink/api/1.2/org/eclipse/persistence/sessions/UnitOfWork.html#getUnitOfWorkChangeSet()
http://www.eclipse.org/eclipselink/api/1.2/org/eclipse/persistence/sessions/changesets/UnitOfWorkChangeSet.html
Syvalta wrote:
Hi,
Is there any way to know what has changed in a transaction, something like a transaction listener? Something in lines of "transaction committed, entity x updated, entity y removed, entity z persisted". If I understood JPA specification correctly, entity listeners are called independent of the transaction, so if commit fails entity listeners for some of the entities might already got called.
Some use cases I have in mind: change log of the system configuration, applying configuration changes to a running system (think for example of mail server which can be configured from web ui).
Any ideas/comments/pointers really appreciated.