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: How to iterate over two (or more) collections simultaneously ?
Date Thu, 23 Oct 2008 02:51:40 GMT
Simple answer - no.

You could make a List of HashMaps to accomplish this:

<iterate property="listOfMaps" open="(" close=")" conjunction=",">
    $listOfMaps[].name$ $listOfMaps[].type$
</iterate>

It's a little more work on the Java side of things, but it will work.

Jeff Butler




On Wed, Oct 22, 2008 at 5:18 PM, Pascal Jacob <zartc@wanadoo.fr> wrote:
> Hi again,
>
> Is it possible to iterate over two (or more) collections SIMULTANEOUSLY
> using the same indice ?
>
> Here is a example:
>
>   <parameterMap id="create-data-table-param" class="java.util.HashMap">
>       <parameter property="names" javaType="string" /> <!-- really an array
> of string -->
>       <parameter property="types" javaType="string" /> <!-- really an array
> of string -->
>   </parameterMap>
>     <statement id="create-data-table"
> parameterMap="create-data-table-param">
>       CREATE TABLE data
>           <!-- what would be the name to set in the property attribute ? -->
>           <iterate property="???" open="(" close=")" conjunction=",">
>               <!-- I want the names and types collections to be iterated in
> synch -->
>               $names[]$ $types[]$
>           </iterate>
>   </statement>
>
> Nested iterate statements won't do it because it produce n*n outputs instead
> of just n (n is the number of elements in the collections).
>
> Any help would be appreciated.
>
>
>
>

Mime
View raw message