Hi Brill,
thanks for replying. The thing is, that only certain parts (e.g. an
entity with certain id including child objects) have to get synchronized
at the time by demand of a content editor.
The datastore is mysql 5.
Jonas
Brill Pappin schrieb:
Actually, the most obvious approach is not to write some special code, but
simply enable replication and don't worry about trying to get OJPA to sync.
What kind of database is it (most popular db's have replication of one sort
or another)?
- Brill Pappin
-----Original Message-----
From: Jonas Petersen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 30, 2008 3:25 PM
To: [email protected]
Subject: Synchronizing two databases with the same model
Hi there!
We have one data model and we need two datastores with that same data model.
Datastore A for editing and previewing and datastore B for production
(live).
Now we need to synchronize parts of datastore A to datastore B.
The most obvious approach would be: fetch objects from datastore A (and
possibly detach the objects) and then merge them in database B. But this
rises a couple of problems due to versioning / sequence generators /
optimistic locking / ...
e.g.:
- If objects (detached from datastore A) do not exist in datastore B, they
are assumed deleted and an exception is thrown
- Since we're using the GeneratedValue annotation for ids, objects would not
be able to get persisted in datastore B even if they were new.
Do you have any idea how to solve this problem in a regular way?
One (non JPA-)way would be to implement it with native queries. Maybe this
is the only way? Would probably be harder to maintain though.
Thanks for any suggestion!
Regards
Jonas