openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: Synchronizing two databases with the same model
Date Wed, 07 May 2008 19:27:35 GMT

Hi,
> 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 / ...

  Another alternative approach is to consider is a single StoreManager with
two database connections: one is 'read' connection to 'source' database and
the other is 'write' connection to 'target' database. The JPA EntityManager
interface remains intact but, below the hood, all 'read' operations happen
on 'source' database while any modification is written to target database. 

  I prefer this approach because then all the instances are managed by the
same persistence context; rather than being realized in one context,
detached and then merged onto another. Also the 'migration application'
becomes simple. One can issue a query, dirty all the selected instance and
then commit. The effect will be migrating all the selected objects from the
'source' database to 'target' database.
   

  Now OpenJPA Slice module already has some support to handle multiple
databases in a same persistence context. I tweaked Slice a bit to get the
'migration' feature as described above.  

  If you are interested to explore this further, let me know.


-- 
View this message in context: http://www.nabble.com/Synchronizing-two-databases-with-the-same-model-tp16989856p17112416.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message