ObjectChangeSet always null [message #555708] |
Fri, 27 August 2010 14:03  |
Eclipse User |
|
|
|
Hi All,
I need to get object changed set before calling entityManager merge() method, so before the transaction is committed.
I always get null when calling getObjectChangeSetForClone(objectToBeUpdated).
The code I'm using is:
JpaEntityManager jpaEntityManager = (JpaEntityManager)em.getDelegate();
UnitOfWorkChangeSet changeSet = (UnitOfWorkChangeSet)jpaEntityManager.getUnitOfWork().getCur rentChanges();
ObjectChangeSet objChangedSet = changeSet.getObjectChangeSetForClone(objectToBeUpdated);
objChangedSet is null no meter if the objectToBeUpdated is dirty or not.
There is any additional configuration property I have to add in persistence.xml to get this working?
How can I get the object change set without extending DescriptorEventAdapter?
Thanks!
|
|
|
|
|
Re: ObjectChangeSet always null [message #556723 is a reply to message #555708] |
Thu, 02 September 2010 09:02  |
Eclipse User |
|
|
|
getCurrentChanges() will return all changes made in the persistence unit.
getObjectChangeSetForClone() will only return the local object's change (if any), it will include any changes to any mapped attribute (basic, 1-1, 1-m, embedded, etc.). If the relationship did not change (i.e. added/removed, different object) then there will be no change for the relationship, even if the target of the relationship changed. The targets changes will be in their own change set.
So you will need to look up the change sets for the related objects to see if they changed.
|
|
|
Powered by
FUDForum. Page generated in 0.03419 seconds