Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Syncing two databases(Merging record deletes for detached entities.)
Syncing two databases [message #675891] Wed, 01 June 2011 16:08 Go to next message
Eclipse UserFriend
Hi everyone,

I've been trying to look for an answer for this for a couple of days but can't quite seem to find one (mainly because perhaps I don't know the proper wording so bear with me).

Basically we have a sort of client/server style application but one in which the clients go offline for long periods of time and then need to sync up. So the client or "mobile" databases are JavaDB/Derby and the server database is Oracle. For some tables, the server is the only source that creates records, and for others only the mobile DB's create the records.

I have the sync currently working *almost* perfectly using Eclipslink 2.0, two Persistence Units and only syncing those tables which the two have in common (as there are some tables we don't want sync'd). But where I draw a blank is when it comes to merging deleted entities. That is, on the server side the record has since been removed and when the two sync up I need the mobile DB to realize that "hey, this record has been deleted, I need to delete as well".

I looked into @PrivateOwned, cascade delete, etc but they seem to all work on relationship/Joins within an entity and not on the entity class itself. Maybe I'm missing something, as I'm sure there's a way to do this properly.

Thank you for your time.

Cheers,
Jeff
Re: Syncing two databases [message #676037 is a reply to message #675891] Thu, 02 June 2011 11:12 Go to previous messageGo to next message
Eclipse UserFriend
You need to compare every object in the one database with the other. If the object is on one, database but not the other, it means that either if was inserted in one, or deleted in the other.
There is no way to no which, other than application logic. If your application does not know, you may need to keep some kind of indicator in your object or database.

If the object was removed, then you just call remove() on the EntityManager with the object to deleted it.
Re: Syncing two databases [message #676838 is a reply to message #676037] Mon, 06 June 2011 13:20 Go to previous message
Eclipse UserFriend
Thanks James. I was afraid of that, but no biggie to implement. I just thought there might have been a cleaner, more JPA standard approach.
Previous Topic:(no subject)
Next Topic:automatic schema update
Goto Forum:
  


Current Time: Tue Jul 01 18:56:25 EDT 2025

Powered by FUDForum. Page generated in 0.06989 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top