Syncing two databases [message #675891] |
Wed, 01 June 2011 20:08 |
jdbethun Messages: 3 Registered: June 2011 |
Junior Member |
|
|
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 15:12 |
|
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.
James : Wiki : Book : Blog : Twitter
|
|
|
|
Powered by
FUDForum. Page generated in 0.39528 seconds