I'm trying to identify which fields of a Persistable object are dirty, but running into what seems to be conflicting information from the NucleusJDOHelper functions. I don't know if this is expected behaviour, or a bug.
When creating a new Persistable object, in an event listener, I can retrieve the persistable object and check:
{
tx.begin();
Student p = new Student("First Student");
p.setAddress(new Address(new Street[]{new Street("Regina")}));
pm.makePersistent(p);
tx.commit();
}
public void postStore(InstanceLifecycleEvent event) {
Persistable pc = (Persistable)event.getSource();
PersistenceManager pm = (PersistenceManager)pc.dnGetExecutionContext().getOwner();
NucleusLogger.GENERAL.info("Audit : postStore for " + ((Persistable) event.getSource()).dnGetObjectId());
NucleusLogger.GENERAL.info("Audit: Object Dirty : " + NucleusJDOHelper.isDirty(pc));
NucleusLogger.GENERAL.info("Audit: Dirty Fields : " + NucleusJDOHelper.getDirtyFields(pc, pm));
}
I get the following output:
16:23:04,262 (main) INFO [DataNucleus.General] - Audit : postStore for mydomain.model.Student-1
16:23:04,262 (main) INFO [DataNucleus.General] - Audit: Object Dirty : true
16:23:04,262 (main) INFO [DataNucleus.General] - Audit: Dirty Fields : null
Is that expected behaviour? That the list of dirty fields is empty if it is a new object, but the object is considered dirty?
If so, is there any way to get a list of the fields that have been set in the new object?
Thanks,
Eric