Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 69327 invoked from network); 1 Dec 2006 16:31:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Dec 2006 16:31:44 -0000 Received: (qmail 82985 invoked by uid 500); 1 Dec 2006 16:31:50 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 82775 invoked by uid 500); 1 Dec 2006 16:31:49 -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 82763 invoked by uid 99); 1 Dec 2006 16:31:49 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Dec 2006 08:31:49 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=HTML_00_10,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of rickcr@gmail.com designates 66.249.92.174 as permitted sender) Received: from [66.249.92.174] (HELO ug-out-1314.google.com) (66.249.92.174) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Dec 2006 08:31:38 -0800 Received: by ug-out-1314.google.com with SMTP id m2so2217439ugc for ; Fri, 01 Dec 2006 08:31:16 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=CFyhNZZPe5bXmkBS/UwNUgITwdjxGRZHUcOrDxqgc7/i9vbuuS8xZ9dPiaYTx2ruivq+cNSr9mPqRQhwMdSMsPUlQYw5mQJ2v3fqrNwyrg/I7kkydxIB/xJzwfHd3C0w8FDPmcsRS84bFJlYhB1kX99D3DfOoBYd9XxCbCB2T7o= Received: by 10.66.216.20 with SMTP id o20mr7517349ugg.1164990676268; Fri, 01 Dec 2006 08:31:16 -0800 (PST) Received: by 10.66.251.16 with HTTP; Fri, 1 Dec 2006 08:31:16 -0800 (PST) Message-ID: <583d4dff0612010831p5a11f937m9b5d6d3493c3707d@mail.gmail.com> Date: Fri, 1 Dec 2006 11:31:16 -0500 From: "Rick Reumann" To: user-java@ibatis.apache.org Subject: Questions on allowing users to switch to a different datasource MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2750_2325888.1164990676169" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_2750_2325888.1164990676169 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm a slacker and not using Spring to create any iBATIS daos. In my existing application I'd like to allow the user to be able to to switch between going against a dev or test/qa db. What I was thinking of doing is... 1) app start up (or lazy on first base dao call), I'd populate two SqlMapClient objects (one dev, one test). This creates a bit of problem, though, since I've been building the SqlMapClient object as SqlMapClientBuilder.buildSqlMapClient(reader); -- but the reader reads from the sqlMapConfig file which points to my datasource. I don't mind duplicating that config file and have each point to the datasource I want, but it seems there must be a better way to set it up since each file would end up with all the duplicate sql map definitions, etc. 2) Users then get their own dao in Session which has a handle to either the dev or qa SqlMapClient. If the user switches to another datasource (picks from a drop down in the front end), the sqlMapClient in their dao instance will point to the new one they chose. I haven't figured out how I want to handle the service layer, but that part won't be bad. I'm more concerned at this point as the approaches others have taken. Thanks. ------=_Part_2750_2325888.1164990676169 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm a slacker and not using Spring to create any iBATIS daos.

In my existing application I'd like to allow the user to be able to to switch between going against a dev or test/qa db.

What I was thinking of doing is...

1) app start up (or lazy on first base dao call), I'd populate two SqlMapClient objects (one dev, one test). This creates a bit of problem, though, since I've been building the SqlMapClient object as SqlMapClientBuilder.buildSqlMapClient (reader); -- but the reader reads from the sqlMapConfig file which points to my datasource. I don't mind duplicating that config file and have each point to the datasource I want, but it seems there must be a better way to set it up since each file would end up with all the duplicate sql map definitions, etc.

2) Users then get their own dao in Session which has a handle to either the dev or qa SqlMapClient. If the user switches to another datasource (picks from a drop down in the front end), the sqlMapClient in their dao instance will point to the new one they chose.

I haven't figured out how I want to handle the service layer, but that part won't be bad.

I'm more concerned at this point as the approaches others have taken.

Thanks.
------=_Part_2750_2325888.1164990676169--