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: Using java.util.List as the parameterClass
Date Tue, 18 Sep 2007 14:40:07 GMT
You can't do it directly.  However, I think that if you put the list in a
map (or some other object), then you can do it:

Map parms = new HashMap();
parms.put ("items", someList);

Then in your SqlMap:

   <select id="countPeopleWithSurname" parameterClass="java.util.Map"
resultClass="int">
      SELECT count(*) FROM person WHERE per_last_name = #items[0]#
   </select>

Jeff Butler



On 9/18/07, Peter Martin <pmartin@adobe.com> wrote:
>
> I want to pass in a List as a parameter class and select the first item
> from the list. I know it is possible to use the <iterate> tag, but is it
> possible to pull out a single item for a given index? For example, in the
> following select I to get the item at position 0:
>
>    <select id="countPeopleWithSurname" parameterClass="java.util.List"
> resultClass="int">
>       SELECT count(*) FROM person WHERE per_last_name = <item 0>
>    </select>
>
>
> Likewise in an insert I may want to pull out the different items:
>
>
> <insert id="insertPerson" parameterClass="person">
> INSERT INTO PERSON (PER_ID, PER_FIRST_NAME, PER_LAST_NAME,
> PER_BIRTH_DATE, PER_WEIGHT_KG, PER_HEIGHT_M) VALUES (<item 0>,
> <item 1>, <item 2>, <item 3>, <item 4>, <item 5>)
> </insert>
>
>
> Thanks
> Peter
>
>
>
>
>
>

Mime
View raw message