Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 34860 invoked from network); 23 Aug 2007 17:57:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Aug 2007 17:57:57 -0000 Received: (qmail 51189 invoked by uid 500); 23 Aug 2007 17:57:53 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 50603 invoked by uid 500); 23 Aug 2007 17:57:52 -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 50589 invoked by uid 99); 23 Aug 2007 17:57:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 10:57:51 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of larry.meadors@gmail.com designates 66.249.90.181 as permitted sender) Received: from [66.249.90.181] (HELO ik-out-1112.google.com) (66.249.90.181) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2007 17:57:49 +0000 Received: by ik-out-1112.google.com with SMTP id b35so249112ika for ; Thu, 23 Aug 2007 10:57:26 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=sZ2ctdgbtyOsmZ2fc58Ll2N4vggwqJH4Zk4TV8JWAeLlfeZRaVLisLR1IRb2G6/Vyk4PgfQXnQzJLJPT9wy6ieR4g+zYhUCook0zbOUC4LW2PNJcYeR46MwqgcZSI3LgQAAPBmT+ObKSrgaD0h2M2x8AEopdJaUpX/LegPMMgMI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=B0orW8UsV8295XsnuydTwb+LeJkbbXGN9rDKVcuaBUiwoHkKsdnxmQkwh1zgaF5ZmNDWIS6ZkFLsfhVwQ9yYgALDEEeJ/yWUL7ziqvEbQAW35r4waVOo1yafGw8pbArdZjdlO0LwR5VIFXgBxGGWDgfW28PeRGQENMOE9/hv5Ow= Received: by 10.78.123.4 with SMTP id v4mr1385054huc.1187891845411; Thu, 23 Aug 2007 10:57:25 -0700 (PDT) Received: by 10.78.143.9 with HTTP; Thu, 23 Aug 2007 10:57:25 -0700 (PDT) Message-ID: Date: Thu, 23 Aug 2007 11:57:25 -0600 From: "Larry Meadors" Reply-To: lmeadors@apache.org Sender: larry.meadors@gmail.com To: user-java@ibatis.apache.org Subject: Re: Fetching ids from oracle and postgresql sequences In-Reply-To: <000101c7e59f$5fd0d1f0$0301a8c0@VAIOSZ330> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46CDAB65.6080305@genedata.com> <000101c7e59f$5fd0d1f0$0301a8c0@VAIOSZ330> X-Google-Sender-Auth: 2ce472f9840a7869 X-Virus-Checked: Checked by ClamAV on apache.org Another approach that work well is to include the sql for this, then define it as a property in your configuration (sqlmapconfig.properties). Larry On 8/23/07, Jean-Francois Poilpret wrote: > Hello Bernd, > > My current way of doing it (far from perfect I must admit) is to manage one > sqlmaps xml file per supported DB. All statements have the same name. I know > this makes a lot of redundant SQL but it makes it easier not only to manage > each DBMS way to manage sequences/identities and also other differences in > the SQL language (eg, I don't know now, but last time I checked, Oracle > still did not support standard SQL outer joins but had its own syntax for > that). Finally it allows specific optimization (only if required, I don't > advise to make SQL optimization systematic, but only on-demand), which is > most often specific to each DBMS. > In my situation (only a few dozen statements for a small DB model), this > fits perfectly. However, with large DB models, hence high number of > statements this could become more difficult to manage. > > Besides this, that approach differs from yours mainly in the fact that there > is only one Java code location where the choice must be handled: that's > where the SqlMapsClient is initialized, nowhere else. > > Of course, it is also possible (but I did not try it) to have a common xml > file for common sql queries and only have separate files for specific > queries; that is OK when you know beforehand which DBMS you will have to > support during the whole lifecycle of your system. However, if you intend to > add support to other DBMS in the future then this approach will probably > become messy (because previously common SQL for 2 DBMS A & B, might not be > common anymore when you put DBMS C into the picture...) > > Cheers > > Jean-Francois > > > -----Original Message----- > From: Bernd Kappler [mailto:Bernd.Kappler@genedata.com] > Sent: Thursday, August 23, 2007 10:45 PM > To: user-java@ibatis.apache.org > Subject: Fetching ids from oracle and postgresql sequences > > Hi, > > we have an application that should work with oracle and postgresql as a > database backend. Unfortunately, the syntax for getting values from a > sequence is slightly different for both databases and we therefore > cannot use the same sql for both. > > Has somebody solved this problem already? Where would be the best place > to do the switch? Would you recommend to create two different statements > and do the switching in the java code, i. e. something like > > > > > > and in java > > if (sqlMapClient.getCurrentConnection() instanceof > OracleConnection) { > > sqlMapClient.queryForObject("getNextFromSequence-Oracle"); > } else { > > sqlMapClient.queryForObject("getNextFromSequence-Postgresql"); > } > > or is there a clever way to do that with dynamic sql? > > Best regards > > Bernd > > > > > > >