Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to compare entities from two different databases and replace one with the other?

Assuming the objects have the same primary keys, you could read from one and
call merge() into the other.  This would merge any changes, or do nothing if
no changes.

There is a compareObjects() method on AbstractSession that will compare two
objects and return if they match.

If you get the UnitOfWork after merging you can get the UnitOfWorkChangeSet
that contains the set of changes.

There is also a compareForChange() method on ObjectBuilder that will compare
two objects and build an ObjectChangeSet.

Doing this for an entire database may take a while depending on the database
size.  You may be better off using lower level database utilities, or just
drop the test db, and clone the reference.


saasira wrote:
> 
> Hi all,
> 
>     I need to compare data in two databases, one a test db and the other
> being reference db, and then patch the differences in the database that is
> being compared from the
>     data in the reference db.
> 
>     Can eclipselink detect changes between two entities, each loaded by
> a different entity manager?
> 
>     Can I use the eclipselink change tracking api ( merge the comparable
> entity with reference entity manager and then invoke UnitOfWork.
> getUnitOfWorkChangeSet() or
>     UnitOfWork.getCurrentChanges() ) for finding the differences between
> the
> test entity and the reference enitity?
> 
> 
>    I'm open to any other approach that can help me achieve this; even
> hibernate or openjpa is also ok to me!
> 
> Thanks and Regards,
> Samba
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 


-----
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://old.nabble.com/How-to-compare-entities-from-two-different-databases-and-replace-one-with-the-other--tp28094979p28164598.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top