Thanks so much for this Thomas. However, the problem here is that what if the value of a column needs to be null intentionally? This will not work in that case. And unfortunately, there is a very high likelihood of this happening in my application.

 

~Rashmi

 


From: Wible, Thomas E [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 16, 2006 6:15 PM
To: Rashmi Dave
Cc: [email protected]
Subject: RE: Selective Update of fields depending on values in object

 

while my predecessor didn't grok the difference between $delimiter$ & #delimiter#, he did come up with exactly what u r looking 4:

 

<sqlmap>

 

 <resultmap id='parameter' class='my.param.obj'>

    <result property='id'        column='id'>

    <result property='name' column='name'>

    <result property='date'   column='date'>

    <result property='value'   column='value'>

...

 </resultmap>

 

<update id='updateParam' parameterClass='my.param.obj'>

    UPDATE paramTable SET

        <dynamic>

            <isNotNull prepend="," property="name">

                name = $name$

            </isNotNull>

            <isNotNull prepend="," property="date">

                date = $date$

            </isNotNull>

            <isNotNull prepend="," property="value">

                value= $value$

            </isNotNull>

        </dynamic>

    WHERE id = $id$

 </update>

 

when i've added columns, i've had to use the # delimiter, but the above works just fine 4 me;-)

Reply via email to