What do you mean by does not work? Are you getting an error, or missing updates?
The listener will be null for any new objects, only existing objects (read from the database) will have a listener. (changes to new objects do not need to be tracked, as they are new, so always changed).
nishitv02 wrote:
ChangeTracking does not work when an object is created from the database and we use the same object pointer to update.
AttributeChangeListener myListener = (AttributeChangeListener) ((ChangeTracker) myObject)
._persistence_getPropertyChangeListener();
Weaving of myObject is happening fine as myObject can be casted to changeTracker.
But myListener is null.
T retVal= (T)getJpaTemplate().execute(new JpaCallback() {
public Object doInJpa(EntityManager em)
throws PersistenceException {
em.persist(t);
..........
return t;
}
}
Is it also the case that For change tracking to work an object needs to be committed to the database ?