Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 72376 invoked from network); 25 Aug 2009 19:18:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Aug 2009 19:18:29 -0000 Received: (qmail 63306 invoked by uid 500); 25 Aug 2009 19:18:53 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 63266 invoked by uid 500); 25 Aug 2009 19:18:53 -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 63258 invoked by uid 99); 25 Aug 2009 19:18:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 19:18:53 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of anoopkumarv@gmail.com designates 209.85.220.220 as permitted sender) Received: from [209.85.220.220] (HELO mail-fx0-f220.google.com) (209.85.220.220) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 19:18:43 +0000 Received: by fxm20 with SMTP id 20so3041320fxm.0 for ; Tue, 25 Aug 2009 12:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=rK8KZaUONO8QUGDaxUs5X4eDFd6wv0AULGJIZvwoBcQ=; b=tITVSZ3P5Nm69YRPLr9wfBmfh23jHrdx7Dj/HdU1AYxTrQJWVYbcmszUiCJ+JQtx/6 MDHZvqtCN5ynzrhnpp8CrHvElFdiVEsOJNANQ77/EOA6h27TBSOX5fcQf9A2QQH0beMZ FEjW4ukpMVDvLhaOiHSZHWpQYEUqy+NO8K/5Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=WuI2Swrk61hbzFuqlMpYRPK8Zj1jFgVs5t0FxMYILSSfTga1XbiyhoLOzYi0/X9jaM RkVf8evT5YOlgATikWMKGKaNCrjgqROSOot7/Rg06O0cIIb4Ip2ceO3JwzEdqOtU3aBc gleDkHiEwmudxQfefn3cWBB9i9tj0gluiglNI= MIME-Version: 1.0 Received: by 10.223.70.13 with SMTP id b13mr5575422faj.31.1251227903165; Tue, 25 Aug 2009 12:18:23 -0700 (PDT) In-Reply-To: <583d4dff0908251202s1c3b3246v533350c3e19662ae@mail.gmail.com> References: <583d4dff0908251116l5a6cba9cxd7d736c8d69e4a56@mail.gmail.com> <583d4dff0908251202s1c3b3246v533350c3e19662ae@mail.gmail.com> From: Anoop kumar V Date: Tue, 25 Aug 2009 15:18:03 -0400 Message-ID: Subject: Re: Newbie question: Update table that has no key / id To: user-java@ibatis.apache.org Content-Type: multipart/alternative; boundary=0015174be39ab386f60471fc32a4 X-Virus-Checked: Checked by ClamAV on apache.org --0015174be39ab386f60471fc32a4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Oops - that is a big typo. I really need to be more careful. Let me set that right and test again. Thanks, Anoop On Tue, Aug 25, 2009 at 3:02 PM, Rick wrote: > no clue what your table looks like but this doesn't seem right: iamsId for > both? > > where > iams_id = #old.iamsId:VARCHAR# > //.... > and isactive=#old.iamsId:VARCHAR# > > > > On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V wrote: > >> Hi Rick, >> >> yes that was one of the typos in my earlier email, but I have corrected >> that among other stuff (embarassing)!! My last email was also copy paste >> from my sqlmap and does not have that issue... My question is about the >> syntax to access a an attribute of an object that is passed as a value of >> map. >> >> Thanks, >> Anoop >> >> >> >> On Tue, Aug 25, 2009 at 2:16 PM, Rick wrote: >> >>> Was that copy and paste? I think you want "new.divisionName" now >>> "newdivisionName" (assuming "new" is the key) >>> >>> >>> On Tue, Aug 25, 2009 at 11:40 AM, Anoop kumar V wrote: >>> >>>> Hi Larry, >>>> >>>> Was wondering if you could help me clarify one thing more... >>>> >>>> I have my sqlmap as below: >>>> >>>> >>>> update user_approvers >>>> set iams_id = #new.iamsId:VARCHAR#, >>>> set region_name = #new.regionName:VARCHAR#, >>>> division_name = #newdivisionName:VARCHAR#, >>>> isactive = #new.isActive:VARCHAR# >>>> where iams_id = #old.iamsId:VARCHAR# >>>> and region_name = #old.regionName:VARCHAR# >>>> and division_name=#old.divisionName:VARCHAR# >>>> and isactive=#old.iamsId:VARCHAR# >>>> >>>> >>>> I am passing a map that has 2 objects which is coming from my bean, the >>>> keys are "old" and "new" and each have a userApprover object as the value. >>>> Map param = new HashMap(); >>>> >>>> So when I put: #new.iamsId:VARCHAR# will the sqlmap be able to >>>> understand that it needs to go inside the map and pull the property from the >>>> bean? >>>> >>>> I am getting the following error when I use it this way: >>>> >>>> 09/08/25 11:29:40 com.ibatis.common.jdbc.exception.NestedSQLException: >>>> --- The error occurred in sqlmap/userapprover_sqlMap.xml. >>>> --- The error occurred while applying a parameter map. >>>> --- Check the updateUserApprover-InlineParameterMap. >>>> --- Check the statement (update failed). >>>> --- Cause: java.sql.SQLException: ORA-01747: invalid user.table.column, >>>> table.column, or column specification >>>> >>>> The other way is that I can completely forget about my bean and just put >>>> everything into my map as , but I dont think that is a very >>>> nice thing to do... any suggestions please? >>>> >>>> Thanks, >>>> Anoop >>>> >>>> >>>> On Mon, Aug 24, 2009 at 10:02 AM, Anoop kumar V wrote: >>>> >>>>> I understand. Thank you very much. >>>>> >>>>> -Anoop >>>>> >>>>> >>>>> >>>>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors < >>>>> larry.meadors@gmail.com> wrote: >>>>> >>>>>> Not if those values can change. >>>>>> >>>>>> If they are immutable, then that makes it easier, because you can >>>>>> update based on them. >>>>>> >>>>>> Larry >>>>>> >>>>>> >>>>>> On Mon, Aug 24, 2009 at 7:10 AM, Anoop kumar V >>>>>> wrote: >>>>>> > Thanks Larry. I think your suggestion will work, but I was hoping >>>>>> > there was an ibatis way of handling this - or that I could use the >>>>>> > database specific rownum or something similar. >>>>>> > >>>>>> > Would it make a big difference if the table had a composite key, >>>>>> such >>>>>> > that no 2 rows have exactly the same column values? >>>>>> > >>>>>> > Thanks again, >>>>>> > Anoop >>>>>> > >>>>>> > On 8/23/09, Larry Meadors wrote: >>>>>> >> You can do it a few ways, I think I'd put the old values and new >>>>>> >> values in a bean, then put those beans in a map and call them "old" >>>>>> >> and "new". >>>>>> >> >>>>>> >> Pass that map to the update and change it to this: >>>>>> >> >>>>>> >> >>>>>> >> update user_approvers set region_name = #new.region:VARCHAR#, >>>>>> >> division_name = #new.division:VARCHAR#, >>>>>> >> where user = #old.user:VARCHAR# >>>>>> >> and region = #old.region:VARCHAR# >>>>>> >> and division=#old.division:VARCHAR# >>>>>> >> >>>>>> >> >>>>>> >> Larry >>>>>> >> >>>>>> >> >>>>>> --------------------------------------------------------------------- >>>>>> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org >>>>>> >> For additional commands, e-mail: user-java-help@ibatis.apache.org >>>>>> >> >>>>>> >> >>>>>> > >>>>>> > >>>>>> > -- >>>>>> > >>>>>> > Thanks, >>>>>> > Anoop >>>>>> > >>>>>> >>>>> >>>>> >>>> >>> >>> >>> -- >>> Rick R >>> >> >> > > > -- > Rick R > --0015174be39ab386f60471fc32a4 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Oops - that is a big typo. I really need to be more careful. Let me set tha= t right and test again.

Thanks,
Anoop


On Tue, Aug 25, 2009 at 3:02 PM, Rick <rickcr@gmail.com> wrote:
no clue what your table looks like but this doesn't seem right: iamsId = for both?

where

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 iams_id =3D #old.iamsId:VARCHAR#=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 //....
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 and isactive=3D#old.iamsId:VARCHAR#



On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <anoopkumarv@gmail.= com> wrote:
Hi Rick,

yes that was one of the typos in my earlier email, but I ha= ve corrected that among other stuff (embarassing)!! My last email was also = copy paste from my sqlmap and does not have that issue... My question is ab= out the syntax to access a an attribute of an object that is passed as a va= lue of map.

Thanks,
Anoop


On Tue, Aug 25, 2009 at 2:16 PM, Rick <r= ickcr@gmail.com> wrote:
Was that copy and paste? I think you want "new.divisionName" now = "newdivisionName" (assuming "new" is the key)
=


On Tue, Aug 25, 2009 at 11:40= AM, Anoop kumar V <anoopkumarv@gmail.com> wrote:
Hi Larry,

= Was wondering if you could help me clarify one thing more...

I have = my sqlmap as below:

<update id=3D"updateUserApprover" parameterClass=3D"j= ava.util.Map">
=A0=A0=A0 update user_approvers
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 set iams_id =3D #new.iamsId:VARCHAR#,
= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 set region_name =3D #new.regionName:VARCH= AR#,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 division_name =3D #newdivisionNam= e:VARCHAR#,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 isactive =3D #new.isActive= :VARCHAR#
=A0=A0=A0 where iams_id =3D #old.iamsId:VARCHAR#
=A0=A0=A0 and region_name =3D #old.regionName:VARCHAR#
=A0=A0=A0 and div= ision_name=3D#old.divisionName:VARCHAR#
=A0=A0=A0 and isactive=3D#old.ia= msId:VARCHAR#
=A0 </update>

I am passing a map that has 2 o= bjects which is coming from my bean, the keys are "old" and "= ;new" and each have a userApprover object as the value.
Map<String, UserApprover> param =3D new HashMap<String, UserApprov= er>();

So when I put: #new.iamsId:VARCHAR# will the sqlmap be abl= e to understand that it needs to go inside the map and pull the property fr= om the bean?

I am getting the following error when I use it this way:

09/08/2= 5 11:29:40 com.ibatis.common.jdbc.exception.NestedSQLException:
--- The = error occurred in sqlmap/userapprover_sqlMap.xml.
--- The error occurred= while applying a parameter map.
--- Check the updateUserApprover-InlineParameterMap.
--- Check the state= ment (update failed).
--- Cause: java.sql.SQLException: ORA-01747: inval= id user.table.column, table.column, or column specification

The othe= r way is that I can completely forget about my bean and just put everything= into my map as <String, String>, but I dont think that is a very nic= e thing to do... any suggestions please?

Thanks,
Anoop


On Mon, Aug 24, 2009 at 10:02 AM, Anoop = kumar V <anoopkumarv@gmail.com> wrote:
I understand. Thank you very much.

-Anoop



On Mon, Aug 24, 2009 at 9:20 AM, Larry M= eadors <larry.meadors@gmail.com> wrote:
Not if those values can change.

If they are immutable, then that makes it easier, because you can
update based on them.

Larry


On Mon, Aug 24, 2009 at 7:10 AM, Anoop kumar V<anoopkumarv@gmail.com> wrote:
> Thanks Larry. I think your suggestion will work, but I was hoping
> there was an ibatis way of handling this - or that I could use the
> database specific rownum or something similar.
>
> Would it make a big difference if the table had a composite key, such<= br> > that no 2 rows have exactly the same column values?
>
> Thanks again,
> Anoop
>
> On 8/23/09, Larry Meadors <larry.meadors@gmail.com> wrote:
>> You can do it a few ways, I think I'd put the old values and n= ew
>> values in a bean, then put those beans in a map and call them &quo= t;old"
>> and "new".
>>
>> Pass that map to the update and change it to this:
>>
>> =A0 <update id=3D"updateUserApprover">
>> =A0 =A0 update user_approvers set region_name =3D #new.region:VARC= HAR#,
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 division_name =3D #new= .division:VARCHAR#,
>> =A0 =A0 where user =3D #old.user:VARCHAR#
>> =A0 =A0 and region =3D #old.region:VARCHAR#
>> =A0 =A0 and division=3D#old.division:VARCHAR#
>> =A0 </update>
>>
>> Larry
>>
>> ------------------------------------------------------------------= ---
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org<= /a>
>> For additional commands, e-mail:
user-java-help@ibatis.apache.org >>
>>
>
>
> --
>
> Thanks,
> Anoop
>





--
Rick R




--
Rick R

--0015174be39ab386f60471fc32a4--