« Return to Thread: Can I use eclipselink to get the differences between two objects?

Re: Can I use eclipselink to get the differences between two objects?

by James Sutherland :: Rate this Message:

Reply to Author | View in Thread

There is no public API to directly do this.

If you have an object registered in an EclipseLink UnitOfWork (any entity managed by an EntityManager), you can get the current changes for it made in the current transaction.  (see UnitOfWork.getCurrentChanges()).

There is an API of Session.compareObjects(), that will return true or false if two objects match, but not a ChangeSet.

If you wish to go under the covers a little their is an API, DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(), that will return an ObjectChangeSet listing the changes between the two objects.


Magnus Heino wrote:
Hi.

Lets say I have

Foo foo = new Foo(2);
Foo foo2 = new Foo(3);

Foo is an @Entity mapped by eclipselink.

Can I somehow use components of eclipselink to compare foo and foo2, and get
a list of differences?

--

/Magnus Heino

 « Return to Thread: Can I use eclipselink to get the differences between two objects?