Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Can I use eclipselink to get the differences between two objects?

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
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Can-I-use-eclipselink-to-get-the-differences-between-two-objects--tp17753109p17756093.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top