ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: iterate over java.Util.List
Date Wed, 14 Jun 2006 15:12:41 GMT
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
> > >
> > >
> > >
> > >
> > >
> >
>

Mime
View raw message