I'm using DN 5.2 with JDO & MSSQL RDBMS.
During a preStore event listener, how can I get access to the original state of the object when it was loaded? I found the following field `org.datanucleus.state.StateManagerImpl#savedImage` but it seems to be null.
According to the javadocs I would have expected that the object be saved as soon as it is loaded from the DB ("Image of the Persistable instance when the instance is enlisted in the transaction.").
Additionally, is there any way to peek at the `savedImage` to retrieve the initial value of given fields during an event?
pm = pmf.getPersistenceManager();
pm.addInstanceLifecycleListener( new StoreLifecycleListener(), null);
tx = pm.currentTransaction();
((JDOTransaction)tx).registerEventListener(audit);
try
{
tx.begin();
Student p = pm.getObjectById(Student.class, 1);
p.setName("Second Student");
tx.commit();
}
In StoreLifecycleListener:
public void preStore(InstanceLifecycleEvent event)
{
Persistable pc = (Persistable)event.getSource();
ObjectProvider op = (ObjectProvider)pc.dnGetStateManager();
// via debug inspection, op.savedImage == null
// similarly, op.restoreFields() does nothing to the pc object
}
Thanks!
Eric