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 Richard Bibb <ri...@aimhedge.com> on 2009/08/26 20:43:56 UTC

Using the foreach statement in iBatis 3.0

Hello

I'm trying to do a select along the lines of 

<select id="selectBackAdjFutureByDateRange"
parameterType="BAFselectByDateRange" resultMap="results">
		select rec_date, int_field,	data_value
		from back_adj_future
		where feed = #{feed}
		and instrument = #{instrument}
		and periodicity = #{periodicity}
		and	int_field in
		<foreach item="item" index="index" collection="list" open="("
separator="," close=")">
			#{item}
		</foreach>
		and rec_date <![CDATA[<]]> #{endDate}
		and rec_date <![CDATA[>]]> #{startDate}
		order by rec_date
</select>

The trouble is the <foreach> statement doesn't seem to work. This is because
I can't tell the statement which of piece of member data from parameterType
the statement will use. (the manual seems to indicate that the List/Array
should be the only parameter. 

Can someone point out what I'm doing wrong (if anything)?
-- 
View this message in context: http://www.nabble.com/Using-the-foreach-statement-in-iBatis-3.0-tp25152935p25152935.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Using the foreach statement in iBatis 3.0

Posted by Jeff Butler <je...@gmail.com>.
The "collection" attribute of the <foreach> tag should the property of
the parameter object that holds the list of values.  From what's
below, iBATIS is expecting a "public List getList()" method in the
BAFselectByDateRange object.

Jeff Butler


On Wed, Aug 26, 2009 at 1:43 PM, Richard Bibb<ri...@aimhedge.com> wrote:
>
> Hello
>
> I'm trying to do a select along the lines of
>
> <select id="selectBackAdjFutureByDateRange"
> parameterType="BAFselectByDateRange" resultMap="results">
>                select rec_date, int_field,     data_value
>                from back_adj_future
>                where feed = #{feed}
>                and instrument = #{instrument}
>                and periodicity = #{periodicity}
>                and     int_field in
>                <foreach item="item" index="index" collection="list" open="("
> separator="," close=")">
>                        #{item}
>                </foreach>
>                and rec_date <![CDATA[<]]> #{endDate}
>                and rec_date <![CDATA[>]]> #{startDate}
>                order by rec_date
> </select>
>
> The trouble is the <foreach> statement doesn't seem to work. This is because
> I can't tell the statement which of piece of member data from parameterType
> the statement will use. (the manual seems to indicate that the List/Array
> should be the only parameter.
>
> Can someone point out what I'm doing wrong (if anything)?
> --
> View this message in context: http://www.nabble.com/Using-the-foreach-statement-in-iBatis-3.0-tp25152935p25152935.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org