I'm trying to include a changes tracker to my JPA Entitys (to a log file, not a database) however the changeSet returned by my DescriptorEventAdapter is always null. I'm using EclipseLink 2.5.2, ojdbc6, spring-orm 4.1.1.
All events are called (including preUpdateWithChanges) and the changes are pushed to the database. I'm using entityManager.merge(entity) to update the entity.
HistoryEventListener.java
public class HistoryEventListener extends DescriptorEventAdapter {
@Override
public void preUpdate(DescriptorEvent event) {
ObjectChangeSet changeSet = event.getChangeSet(); // Always null
}
@Override
public void preUpdateWithChanges(DescriptorEvent event) {
ObjectChangeSet changeSet = event.getChangeSet();
...
};
@Override
public void postUpdate(DescriptorEvent event) {
...
}
@Override
public void postMerge(DescriptorEvent event) {
...
}
}
Some entity
@Entity
@Table(name = "XXX", schema = "XXX")
@EntityListeners(HistoryEventListener.class)
@Cache(databaseChangeNotificationType = DatabaseChangeNotificationType.NONE, isolation = CacheIsolationType.ISOLATED)
public class XXXX implements Serializable {
// id + fields
}
persistence.xml
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="XXXXXX"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/XXXXX</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
<property name="eclipselink.target-database" value="Oracle11" />
</properties>
</persistence-unit>
</persistence>
Using UnitOfWork from eclipse wiki also returns a Null ObjectChangeSet.