Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 49710 invoked from network); 7 Oct 2005 07:35:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Oct 2005 07:35:19 -0000 Received: (qmail 72838 invoked by uid 500); 7 Oct 2005 07:35:13 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 72747 invoked by uid 500); 7 Oct 2005 07:35:13 -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 72713 invoked by uid 99); 7 Oct 2005 07:35:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2005 00:35:13 -0700 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=FORGED_RCVD_HELO,HTML_50_60,HTML_MESSAGE,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [217.160.108.41] (HELO p15092232.pureserver.info) (217.160.108.41) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2005 00:35:15 -0700 Received: (qmail 15801 invoked from network); 7 Oct 2005 09:34:48 +0200 Received: from d031099.adsl.hansenet.de (HELO smtp.prolifics.de) (80.171.31.99) by prolifics.de with SMTP; 7 Oct 2005 09:34:48 +0200 Received: from enterprise.prolifics.de (localhost [127.0.0.1]) by smtp.prolifics.de (Postfix) with ESMTP id 02CAF2ED10 for ; Fri, 7 Oct 2005 09:34:18 +0200 (CEST) In-Reply-To: <43461BD6.2050905@gmail.com> To: user-java@ibatis.apache.org Subject: Antwort: Mutliple database vendor MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.5.3 September 14, 2004 Message-ID: From: marc.heimann@prolifics.de Date: Fri, 7 Oct 2005 09:34:16 +0200 X-MIMETrack: Serialize by Router on enterprise/prolifics(Release 6.5.1|January 21, 2004) at 07.10.2005 09:34:17 AM, Serialize complete at 07.10.2005 09:34:17 AM Content-Type: multipart/alternative; boundary="=_alternative 0029920AC1257093_=" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Dies ist eine mehrteilige Nachricht im MIME-Format. --=_alternative 0029920AC1257093_= Content-Type: text/plain; charset="US-ASCII" We have a similar problem in the very near future and my idea is to use the include-feature to seperate the DB specific code. Have a look at the iBATIS Wiki at http://opensource2.atlassian.com/confluence/oss/pages/viewpage.action?pageId=707 Looks something like this SELECT * FROM tbl_mitarbeiter I might be brave enough to have a look at the parsing source code and try to implement a conditional statement like but I'm not sure if the current amount of workload allows me to do it in a timely fashion. I have not yet evaluated if it is possible to include sql fragments from another xml file, if so I suggest putting the DB specific fragments in their own jars (one for Oracle, one for MySQL) and use whichever you need. Cheers Marc Olivier Ziller GMail Lists schrieb am 07.10.2005 08:55:18: > hello, > > my application have to work both with MySql and Oracle. > Most of my queries work on both database but a few are specific. > Especially those with selectKey... > > What i've done is to make 3 files for statements : one for generic > statements, one for oracle and one for mysql... > > in the mysql file i will have something like : > > > parameterClass="fr.unire.portal.channels.fun.csof.beans.ErreurObjet" > > > insert into FUN_ERR_OBJ values (#numErrObj#, #numObj#, > #codGi#, #numLang#, > > #codInf#, #typErrObj#, #libErrObj#) > > > > select LAST_INSERT_ID() > > > > > > > and in the oracle one, something like : > > > parameterClass="fr.unire.portal.channels.fun.csof.beans.ErreurObjet" > > > > > select FUN_SEQ_ERR_OBJ.nextval from dual > > > > insert into FUN_ERR_OBJ values (#numErrObj:INTEGER#, > #numObj:INTEGER#, #codGi:VARCHAR#, #numLang:INTEGER#, > > #codInf:VARCHAR#, #typErrObj:VARCHAR#, #libErrObj:VARCHAR#) > > > > > i do not like this solution very much because my statements are very > similar except the way to generate a key... > > could you tell me if there is a better way to do that? > > regards --=_alternative 0029920AC1257093_= Content-Type: text/html; charset="US-ASCII"
We have a similar problem in the very near future and my idea is to use the include-feature to seperate the DB specific code.
Have a look at the iBATIS Wiki at http://opensource2.atlassian.com/confluence/oss/pages/viewpage.action?pageId=707



Looks something like this

<sql id="MAselectList_fragment">
      SELECT
            *
    FROM
            tbl_mitarbeiter
  </sql>        
  <select id="leseMitarbeiter" resultMap="mitarbeiterResultMap" parameterClass="int" resultClass="MA">
        <include refid="MAselectList_fragment"/>
    WHERE
            fldPersNr = #value#
     
  </select>


I might be brave enough to have a look at the parsing source code and try to implement a conditional statement like

<if $(database_vendor)=="ORACLE">
        <include refid="oracle_select">
<else>
        <include refid="mysql_select">
<endif>

but I'm not sure if the current amount of workload allows me to do it in a timely fashion.

I have not yet evaluated if it is possible to include sql fragments from another xml file, if so I suggest putting the DB specific fragments in their own jars (one for Oracle, one for MySQL) and use whichever you need.


Cheers
Marc

Olivier Ziller GMail Lists <olivier.ziller.lists@gmail.com> schrieb am 07.10.2005 08:55:18:

> hello,
>
> my application have to work both with MySql and Oracle.
> Most of my queries work on both database but a few are specific.
> Especially those with selectKey...
>
> What i've done is to make 3 files for statements : one for generic
> statements, one for oracle and one for mysql...
>
> in the mysql file i will have something like :
>
>     <insert id="insertErreurObjet"
>
>         parameterClass="fr.unire.portal.channels.fun.csof.beans.ErreurObjet" >
>
>         insert into FUN_ERR_OBJ values (#numErrObj#, #numObj#,
> #codGi#, #numLang#,
>
>         #codInf#, #typErrObj#, #libErrObj#)
>
>         <selectKey keyProperty="numErrObj" resultClass="int">
>
>             select LAST_INSERT_ID()
>
>         </selectKey>
>
>     </insert>
>
>
> and in the oracle one, something like :
>
>     <insert id="insertErreurObjet"
>
>         parameterClass="fr.unire.portal.channels.fun.csof.beans.ErreurObjet" >
>
>         <selectKey keyProperty="numErrObj" resultClass="int">
>
>             select FUN_SEQ_ERR_OBJ.nextval from dual
>
>         </selectKey>
>
>         insert into FUN_ERR_OBJ values (#numErrObj:INTEGER#,
> #numObj:INTEGER#, #codGi:VARCHAR#, #numLang:INTEGER#,
>
>         #codInf:VARCHAR#, #typErrObj:VARCHAR#, #libErrObj:VARCHAR#)
>
>     </insert>
>
>
> i do not like this solution very much because my statements are very
> similar except the way to generate a key...
>
> could you tell me if there is a better way to do that?
>
> regards
--=_alternative 0029920AC1257093_=--