openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Vorburger" <mvorbur...@odyssey-group.com>
Subject RE: Synchronizing two databases with the same model
Date Tue, 06 May 2008 08:34:51 GMT
Jonas,

I wonder if the OpenJPA "Remote and Offline Operation" stuff
(http://openjpa.apache.org/docs/latest/manual/ref_guide_event.html) may
allow you to build what you're after...

Regards,
Michael


-----Original Message-----
From: Andy Schlaikjer [mailto:hazen+@cs.cmu.edu] 
Sent: jeudi, 1. mai 2008 18:44
To: users@openjpa.apache.org
Subject: Re: Synchronizing two databases with the same model

Jonas,

I'm glad you asked this question as I'd also been thinking about how I
might get around restrictions the @GeneratedValue annotation enforces
within OpenJPA.

In certain circumstances I need to specify the value of a field marked
with @GeneratedValue explicitly when persisting a new entity instance. 
I'd hoped that perhaps "merge" semantics would differ from "persist" 
semantics with respect to this constraint, but it seems (quite
logically) that the constraint is applied uniformly to all entity
life-cycle operations.

For the time being I've had to fall back on JDBC to persist new data,
but it'd be great if there were a way to signal to OpenJPA that a field
marked with GeneratedValue may be explicitly defined for certain
operations, like merge or persist.

Andy

Jonas Petersen wrote:
> 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:jonas@mindfloaters.de] Sent: Wednesday, 
>> April 30, 2008 3:25 PM
>> To: users@openjpa.apache.org
>> 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
>>
>>
>>   
> 
> 

____________________________________________________________

 This email and any files transmitted with it are CONFIDENTIAL and intended
  solely for the use of the individual or entity to which they are addressed.
 Any unauthorized copying, disclosure, or distribution of the material within
  this email is strictly forbidden.
 Any views or opinions presented within this e-mail are solely those of the
  author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
 An electronic message is not binding on its sender. Any message referring to
  a binding engagement must be confirmed in writing and duly signed.
 If you have received this email in error, please notify the sender immediately
  and delete the original.

Mime
View raw message