Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 3109 invoked from network); 16 Feb 2006 14:00:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Feb 2006 14:00:09 -0000 Received: (qmail 51668 invoked by uid 500); 16 Feb 2006 14:00:06 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 51646 invoked by uid 500); 16 Feb 2006 14:00:05 -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 51635 invoked by uid 99); 16 Feb 2006 14:00:05 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2006 06:00:05 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.82.202 as permitted sender) Received: from [66.249.82.202] (HELO xproxy.gmail.com) (66.249.82.202) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2006 06:00:04 -0800 Received: by xproxy.gmail.com with SMTP id t11so74735wxc for ; Thu, 16 Feb 2006 05:59:44 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=d6O91+M92UY1sXMnHMRzWhKof3OBAhp/rIaPSpdqkWDOEb70kH1Mm8FNgjwGlM1tdcrH11pxkd81QMGJiGR4LcsRTNnl3v++Q5iGASI467Mcc/FHuMno4xNGFlA4MARWA9FgiZeerAOM16yOb8/5y4YUzoEHlTkJJWdpnkLliwE= Received: by 10.70.117.9 with SMTP id p9mr1121594wxc; Thu, 16 Feb 2006 05:59:42 -0800 (PST) Received: by 10.70.70.13 with HTTP; Thu, 16 Feb 2006 05:59:42 -0800 (PST) Message-ID: Date: Thu, 16 Feb 2006 07:59:42 -0600 From: Jeff Butler To: user-java@ibatis.apache.org Subject: Re: Selective Update of fields depending on values in object In-Reply-To: <200602161320.AHU75548@persistent.co.in> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2596_1553311.1140098382869" References: <3FC24A8C98BD214488C7B6701E1640F10116399C@wdcxh01.mdnt.com> <200602161320.AHU75548@persistent.co.in> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_2596_1553311.1140098382869 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Rashmi has correctly identified the core problem - sometimes you want a column to be null, and sometimes you want to ignore the column. The only way I can think to solve the problem is to have a seperate set of indictors that denote whther you want to ignore the field in the update or not. Has anyone thought of a bettter way? It should be pretty easy to generate this with Abator. Jeff Butler On 2/16/06, Rashmi Dave wrote: > > Thanks so much for this Thomas. However, the problem here is that what i= f > 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:Thomas.E.Wible@mdnt.com] > *Sent:* Thursday, February 16, 2006 6:15 PM > *To:* Rashmi Dave > *Cc:* user-java@ibatis.apache.org > *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: > > > > > > > > > > > > > > > > > > ... > > > > > > > > UPDATE paramTable SET > > > > > > name =3D $name$ > > > > > > date =3D $date$ > > > > > > value=3D $value$ > > > > > > WHERE id =3D $id$ > > > > > > when i've added columns, i've had to use the # delimiter, but the above > works just fine 4 me;-) > ------=_Part_2596_1553311.1140098382869 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Rashmi has correctly identified the core problem - sometimes you want = a column to be null, and sometimes you want to ignore the column.  The= only way I can think to solve the problem is to have a seperate set o= f indictors that denote whther you want to ignore the field in the update o= r not.  Has anyone thought of a bettter way?  It should be pretty= easy to generate this with Abator.
 
Jeff Butler

 
On 2/16/06, = Rashmi Dave <rashmid@per= sistent.co.in> wrote:

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

 

~Rashmi

 


From: Wibl= e, Thomas E [mailto: Thomas.E.Wible@mdnt.com] Sent: Thursday, February 1= 6, 2006 6:15 PM
To: Rashmi Dave
<= span style=3D"FONT-WEIGHT: bold">Cc:
user-java@ibatis.apache.org
Sub= ject: RE: Selective Update of fields depending on values in obje= ct

while my predecessor didn't grok th= e difference between $delimiter$ & #delimiter#, he did come up with exa= ctly what u r looking 4:

<sqlmap>

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

    <result prope= rty=3D'id'        column=3D'id'>

    <result prope= rty=3D'name' column=3D'name'>

    <result prope= rty=3D'date'   column=3D'date'>

    <result prope= rty=3D'value'   column=3D'value'>

...

 </resultmap>

<update id=3D'updateParam' param= eterClass=3D'my.param.obj'>

UPD= ATE paramTable SET

<dynamic>

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

name = =3D $name$

</isNotNull>

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

date = =3D $date$

</isNotNull>

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

value= =3D $value$

</isNotNull>

</dynamic>

WHE= RE id =3D $id$

 </update>=

when i've added columns, i've had t= o use the # delimiter, but the above works just fine 4 me;-)<= /p>


------=_Part_2596_1553311.1140098382869--