Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 67470 invoked from network); 21 Oct 2008 13:54:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Oct 2008 13:54:08 -0000 Received: (qmail 72436 invoked by uid 500); 21 Oct 2008 13:54:08 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 72415 invoked by uid 500); 21 Oct 2008 13:54:07 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 72404 invoked by uid 99); 21 Oct 2008 13:54:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Oct 2008 06:54:07 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of david.mcreynolds@gmail.com designates 72.14.220.156 as permitted sender) Received: from [72.14.220.156] (HELO fg-out-1718.google.com) (72.14.220.156) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Oct 2008 13:52:58 +0000 Received: by fg-out-1718.google.com with SMTP id d23so1823917fga.32 for ; Tue, 21 Oct 2008 06:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=v4qV6UGiI1swdE8XPW4F9RRJB1kTlMPigaFzxEoagFY=; b=IjAofrS8R8DvykAS3X6PCSkHjknAHiDRxe5GF/s5AMZky8vOBYooF6+8gOJE1WbWZ0 uT3qp3h4jNdil/RU3GKQKuThb2jXNqryDFF23uBxE9Cg1EW749ecVgGD6zWdZM8dZ5ET eX5P24OIrlHK5lj8VtseWyVlelSWkucbDk3wQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=g2WenwqtzZfAR0CniUXwJeTvqoFV8oQfcHTeK0RE/RrXyY3UKgV3Av/nRoY0awz7i8 iSajUbXd/d26q/fUaoX6+i5BI3pi+zs67EHNpiZ0p3aan5C1n0+cxUiSfIXt94UVD9Ok z3KfTrwPFanlESzvU3HM+iwsyl/37towO4OYk= Received: by 10.180.204.10 with SMTP id b10mr1172103bkg.201.1224597216276; Tue, 21 Oct 2008 06:53:36 -0700 (PDT) Received: by 10.181.59.15 with HTTP; Tue, 21 Oct 2008 06:53:36 -0700 (PDT) Message-ID: <20c3fff50810210653w4c28b321h150f5f85b1727135@mail.gmail.com> Date: Tue, 21 Oct 2008 09:53:36 -0400 From: "David McReynolds" To: ibatis-user-list Subject: duplicate databases MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_12872_10614024.1224597216264" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_12872_10614024.1224597216264 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Precondition: I know this is a screwy set up. But, it is, what it is. What I need, are ideas for dealing with it, and any heads up dor potential nightmares. We have two databases that are supposed to remain synchronized. For some reason, there is no abstraction layer (hardware or otherwise) that presents the databases as one to the application layer. What I have done so far, is create two sqlMapConfig files which define the two datasources and include the map files. Then, I have an SqlMapClientFactory that accepts a "resourceName" and a "resourceType", the latter being "Primary" or "Secondary", the former being one of many different datasources the application must deal with. Finally, I altered the iBator generated DAO constructors to accept the "resourceName". Then each method has to be get the SqlMapClient instance from the factory (which is caching the references: Primary and Secondary). The bodies of the DAO methods are written with try/catch and the catch blocks attempt the same operation but with the "Secondary" SqlMapClient. Only if the secondary fails is the standard ibatis sql exception allowed to propagate up. -- dlm ------=_Part_12872_10614024.1224597216264 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Precondition: I know this is a screwy set up. But, it is, what it is. What I need, are ideas for dealing with it, and any heads up dor potential nightmares.

We have two databases that are supposed to remain synchronized. For some reason, there is no abstraction layer (hardware or otherwise) that presents the databases as one to the application layer.

What I have done so far, is create two sqlMapConfig files which define the two datasources and include the map files.

Then, I have an SqlMapClientFactory that accepts a "resourceName" and a "resourceType", the latter being "Primary" or "Secondary", the former being one of many different datasources the application must deal with.

Finally, I altered the iBator generated DAO constructors to accept the "resourceName". Then each method has to be get the SqlMapClient instance from the factory (which is caching the references: Primary and Secondary). The bodies of the DAO methods are written with try/catch and the catch blocks attempt the same operation but with the "Secondary" SqlMapClient. Only if the secondary fails is the standard ibatis sql exception allowed to propagate up.

--
dlm
------=_Part_12872_10614024.1224597216264--