Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 33952 invoked from network); 30 Apr 2008 23:13:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Apr 2008 23:13:41 -0000 Received: (qmail 82194 invoked by uid 500); 30 Apr 2008 23:13:42 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 82175 invoked by uid 500); 30 Apr 2008 23:13:42 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 82164 invoked by uid 99); 30 Apr 2008 23:13:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 16:13:42 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [64.233.166.179] (HELO py-out-1112.google.com) (64.233.166.179) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 23:12:56 +0000 Received: by py-out-1112.google.com with SMTP id w49so771083pyg.36 for ; Wed, 30 Apr 2008 16:13:09 -0700 (PDT) Received: by 10.65.211.16 with SMTP id n16mr2736657qbq.36.1209597189093; Wed, 30 Apr 2008 16:13:09 -0700 (PDT) Received: from PTAH ( [99.231.157.49]) by mx.google.com with ESMTPS id e11sm2889687qbc.5.2008.04.30.16.13.06 (version=SSLv3 cipher=RC4-MD5); Wed, 30 Apr 2008 16:13:07 -0700 (PDT) From: "Brill Pappin" To: References: <4818C7A2.6090104@mindfloaters.de> Subject: RE: Synchronizing two databases with the same model Date: Wed, 30 Apr 2008 19:11:40 -0400 Message-ID: <000601c8ab17$8d39c4b0$6900a8c0@pappin.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Thread-Index: Aciq+AAU+tMT2wcvQrqQR1vNqmBtgAAH0rcQ In-Reply-To: <4818C7A2.6090104@mindfloaters.de> X-Virus-Checked: Checked by ClamAV on apache.org 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