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