Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 35274 invoked from network); 14 Jun 2006 15:13:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Jun 2006 15:13:06 -0000 Received: (qmail 96358 invoked by uid 500); 14 Jun 2006 15:13:04 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 96338 invoked by uid 500); 14 Jun 2006 15:13:03 -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 96327 invoked by uid 99); 14 Jun 2006 15:13:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jun 2006 08:13:03 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jeffgbutler@gmail.com designates 66.249.92.171 as permitted sender) Received: from [66.249.92.171] (HELO ug-out-1314.google.com) (66.249.92.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jun 2006 08:13:02 -0700 Received: by ug-out-1314.google.com with SMTP id k3so367329ugf for ; Wed, 14 Jun 2006 08:12:41 -0700 (PDT) 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=eRanPCz6Qp+KvLLgZJ6xh4/lRsSP9NVnnoz2y5x728wA9HQRleohlYqbZm92qotf7PoP4mPn6XB5gv0iZqhuOqwvSSH32N2oRJS++cVGpkGIWHOn86BcTyMK2cM2qYLP2pLC7chDArBR6JnR230FJN1dgzUlunh9omX6GD9jAwc= Received: by 10.67.101.8 with SMTP id d8mr356675ugm; Wed, 14 Jun 2006 08:12:41 -0700 (PDT) Received: by 10.66.238.18 with HTTP; Wed, 14 Jun 2006 08:12:41 -0700 (PDT) Message-ID: Date: Wed, 14 Jun 2006 10:12:41 -0500 From: "Jeff Butler" To: user-java@ibatis.apache.org Subject: Re: iterate over java.Util.List In-Reply-To: <3c8cea400606140631j7d33738ai89b8c6706e1d4a96@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_6477_13899694.1150297961190" References: <449006c1.7c51c4e6.7ee6.19c1@mx.gmail.com> <3c8cea400606140631j7d33738ai89b8c6706e1d4a96@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_6477_13899694.1150297961190 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline You are correct Debasish - sorry for my misinformation. The docs are a little ambiguous about this usage so I'll make it clearer - thanks! Jeff Butler On 6/14/06, Debasish Dutta Roy wrote: > > Hi All > First and foremost you can surely pass the List object as a parameter. I > have done that many times. > > Please do the following... > > List argList is your list containing all the IN values > > > > #[]# > > > > Java code > mapClient.queryForList ("myMethod", argList); > > Will sure work. > > > On 6/14/06, Jeff Butler wrote: > > > > You cannot pass the list directly as the parameter object - the list > > needs to be a property of some other object. You could put the list in a > > map: > > > > Map map = new HashMap(); > > map.put("list", theList); > > > > then make your parameter class java.util.Map > > > > Jeff Butler > > > > > > On 6/14/06, Rashmi Dixit wrote: > > > > > > Hi, > > > > > > I have a select statement to which I want to attach a where clause > > > with > > > an "IN". The values for the IN are BigDecimals which I would like to > > > pass as a java.util.List. (Note: I know this list will not be empty, > > > will be adding dynamic prepend later). > > > > > > > > > > > > I am getting an error when I execute this > > > > > > --- Check the parameter map. > > > --- Cause: java.lang.StringIndexOutOfBoundsException: String index out > > > of range: -2 > > > > > > What am I doing wrong here? Even if I use "value" instead of "list" as > > > the property value, I get the same exception. I haven't been able to > > > find enough iterate examples even after a google search. All examples > > > iterate over some property of the parameter class or a Map. > > > > > > Any help will be appreciated. > > > > > > Regards > > > ~Rashmi > > > > > > > > > > > > > > > > > > ------=_Part_6477_13899694.1150297961190 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
You are correct Debasish - sorry for my misinformation.  The docs are a little ambiguous about this usage so I'll make it clearer - thanks!
 
Jeff Butler

 
On 6/14/06, Debasish Dutta Roy <debasish.duttaroy@gmail.com> wrote:
Hi All
First and foremost you can surely pass the List object as a parameter. I have done that many times.

Please do the following...

List argList is your list containing all the IN values

        <dynamic prepend="WHERE">
            <iterate open="external_key IN(" close=")" conjunction=",">
                #[]#
            </iterate>
        </dynamic>

Java code
mapClient.queryForList ("myMethod", argList);

Will sure work.


On 6/14/06, Jeff Butler <jeffgbutler@gmail.com > wrote:
You cannot pass the list directly as the parameter object - the list needs to be a property of some other object.  You could put the list in a map:
 
Map map = new HashMap();
map.put("list", theList);
 
then make your parameter class java.util.Map
 
Jeff Butler

 
On 6/14/06, Rashmi Dixit <rashmid@gmail.com> wrote:
Hi,

I have a select statement to which I want to attach a where clause with
an "IN". The values for the IN are BigDecimals which I would like to
pass as a java.util.List. (Note: I know this list will not be empty,
will be adding dynamic prepend later).

<select id="trial" resultMap="uploadQueueResult"
parameterClass="java.util.List ">
       select ID from sometable
         WHERE
               <iterate property="list"
                       open="FACILITYID in ("
                       close=")"
                       conjunction=",">
                       #list[]#
               </iterate>
</select>

I am getting an error when I execute this

--- Check the parameter map.
--- Cause: java.lang.StringIndexOutOfBoundsException: String index out
of range: -2

What am I doing wrong here? Even if I use "value" instead of "list" as
the property value, I get the same exception. I haven't been able to
find enough iterate examples even after a google search. All examples
iterate over some property of the parameter class or a Map.

Any help will be appreciated.

Regards
~Rashmi







------=_Part_6477_13899694.1150297961190--