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 22:36:37 GMT

Hi Jonas,
  Just finished a prototype that specializes Slice to migrate selected
instances from one database to another. But I am not planning to commit it
to trunk right now (mainly because the trick that made it work will require
a single line but dangerous change in OpenJPA :) -- if you are interested I
can send you a small jar (~20KB) that you can play with and give us some
feedback on feasibility of this approach. 

  Additional information on Slice is available at [1][2][3] and also is
documented on SVN trunk. 

[1] http://people.apache.org/~ppoddar/slice/site/index.html
[2]
http://dev2dev.bea.com/blog/pinaki.poddar/archive/2007/12/slice_openjpa_f.html
[3]
http://dev2dev.bea.com/blog/pinaki.poddar/archive/2008/01/slice_openjpa_f_1.html


Jonas Petersen wrote:
> 
> Hi Pinaki,
> 
> thank you, this sounds interesting. The Slice Plig-In looks quite 
> promising, I'm definitely interested in learning more about this.
> 
> Jonas
> 
> 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 this message in context: http://www.nabble.com/Synchronizing-two-databases-with-the-same-model-tp16989856p17116073.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message