You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Balwinder Sodhi <ba...@gmail.com> on 2005/10/03 06:33:38 UTC

Select query

Hello,

My requirement is to place a query like:

SELECT a, b, c FROM my_table WHERE a IN (some_list)

in the SQLMap. Now this 'some_list' can be an instance of
java.util.List or java.util.Collection etc. I am not able to figure
out how can I configure such a query.

Can this be done by using some construct like:

<!-- Assuming myResult etc. is defined -->
<select id="getMyData" resultMap="myResult" parameterClass="what_to_put_here?">
SELECT a, b, c FROM my_table WHERE a IN (#what_to_put_here?#)
</select>

Any help will be greatly appreciated.

Regards,
Balwinder

Re: Select query

Posted by Zarar Siddiqi <za...@utoronto.ca>.
<iterate> : Iterates over a property that is of type java.util.List

Example Usage:

<iterate prepend="AND" property="userNameList" open="(" close=")" 
conjunction="OR">
     username=#userNameList[]#
</iterate>

Note: It is very important to include the square brackets[] at the end of 
the List property name when using the Iterate element. These brackets 
distinguish this object as an List to keep the parser from simply outputting 
the List as a string.

This is from Page 39 of the Java Developer Guide.

Zarar


----- Original Message ----- 
From: "Balwinder Sodhi" <ba...@gmail.com>
To: <us...@ibatis.apache.org>
Sent: Monday, October 03, 2005 12:33 AM
Subject: Select query


> Hello,
>
> My requirement is to place a query like:
>
> SELECT a, b, c FROM my_table WHERE a IN (some_list)
>
> in the SQLMap. Now this 'some_list' can be an instance of
> java.util.List or java.util.Collection etc. I am not able to figure
> out how can I configure such a query.
>
> Can this be done by using some construct like:
>
> <!-- Assuming myResult etc. is defined -->
> <select id="getMyData" resultMap="myResult" 
> parameterClass="what_to_put_here?">
> SELECT a, b, c FROM my_table WHERE a IN (#what_to_put_here?#)
> </select>
>
> Any help will be greatly appreciated.
>
> Regards,
> Balwinder
>