ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alejandro D. Garin" <aga...@gmail.com>
Subject Re: <update> with parameterMap and parameterClass ?
Date Wed, 26 Nov 2008 17:08:33 GMT
Hi Nicholoz,

OK, I understand, but with the following example:

    <parameterMap id="messageParameterMap" class="Message">
        <parameter property="id1" jdbcType="INTEGER"/>
        <parameter property="id2" jdbcType="INTEGER"/>
        <parameter property="messageCount" jdbcType="INTEGER" />
        <parameter property="title" jdbcType="VARCHAR"/>
    </parameterMap>

    <insert id="insertMessage" parameterMap="messageParameterMap" >
        INSERT INTO MSGS ( SY_ID1, SY_ID2, MS_COUNT, MS_TITLE)
        VALUES (?,?,?,?)
    </insert>

    <update id="update" parameterMap="messageParameterMap" >
        UPDATE MSGS SET MS_COUNT=?, MS_TITLE=? WHERE SY_ID1=? AND SY_ID2 = ?
    </update>

How to indicate in the update statement that the SY_ID1 AND SY_ID2 must be
in the where? I must change the order of the parameterMap ?

Thanks

On Wed, Nov 26, 2008 at 12:16 PM, Nicholoz Koka Kiknadze <kiknadze@gmail.com
> wrote:

>
>
> On Wed, Nov 26, 2008 at 8:05 AM, Alejandro D. Garin <agarin@gmail.com>wrote:
>
>> Hi Ingmar
>>
>>
>>> provide an instance of Person as parameter, witch contains the values to
>>> store.
>>>
>>> <update id="update1" parameterClass="Person">
>>>  UPDATE Person SET
>>>    name = #name:VARCHAR#,
>>>    lastname = #lastname:VARCHAR#
>>>  WHERE id = #id:INTEGER#
>>> </update>
>>>
>>
>> OK, but, what if I have defined a parameterMap for an <insert>? can't
>> reuse it for an <update> statement?
>>
>
> Sure you can reuse it:
> <update id="update1" parameterMap="personMap"> ... </update>
>
> You can not use BOTH parameterMap and parameterClass in a single update
> definition, so if you already have defined and populated your parameterMap,
> go ahead, use it.
>
>

Mime
View raw message