openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Petersen <>
Subject Re: Synchronizing two databases with the same model
Date Wed, 07 May 2008 20:01:26 GMT
Hi Pinaki,

thank you, this sounds interesting. The Slice Plig-In looks quite 
promising, I'm definitely interested in learning more about this.


Pinaki Poddar schrieb:
> 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 raw message