ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Ziller GMail Lists <olivier.ziller.li...@gmail.com>
Subject Mutliple database vendor
Date Fri, 07 Oct 2005 06:55:18 GMT
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

Mime
View raw message