This the the Dachs module for EclipseLink.
<dependency>
<groupId>com.ethlo.dachs</groupId>
<artifactId>dachs-eclipselink</artifactId>
<version>${dachs.version}</version>
</dependecy>
spring.jpa.properties.eclipselink.session.customizer=com.ethlo.dachs.eclipselink.DachsSessionCustomizer
@Bean
public EntityChangeSetListener entityChangeSetListener()
{
return new EntityChangeSetAdapter()
{
@Override
public void postDataChanged(EntityDataChangeSet changes)
{
// Will be triggered after commit
}
}
}
For auditing purposes, one normally is not interested in an entity's related entities. For example when updating an order that has a reference to a product, we do not want to traverse and log the prodduct entity, we just want to know that the order now references it.
To serialize these changes (and avoiding a huge, potentially recursive graph), Dachs supports IdentityUtil.toIndentityReferences(Collection<EntityDataChange> list)