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 shamim <sr...@yandex.ru> on 2010/05/05 09:18:57 UTC

Does anyone have any example of "foreach" with annotation

Hi All,
  i have stuck with dynamic Sql on Ibatis 3 annotations. Trying to pass List
in dynamic sql as follows:

@Update("update ${schemaName}.fuf uf" +
			" set uf.reestr_date = #{reestDate}," +
			" uf.reestr_number = #{reestNum}" +
			" where uf.reestr_number IS not NULL AND uf.reestr_date IS not NULL and
uf.id in " +
			" <foreach item=\"item\" index=\"index\" collection=\"list\""+
			"	open=\"(\" separator=\",\" close=\")\">"+
			"	#{item}"+
			" </foreach>")
	void updateUpffReesterByList(@Param("schemaName") final String schemaName,
@Param("list") List<Long> list, @Param("reestNum") final String reestNum,
@Param("reestDate") final Date reestDate);

Its always throws JDBC exception. May be i am missing something?
Thank'x in Advance
  Shamim


-- 
View this message in context: http://old.nabble.com/Does-anyone-have-any-example-of-%22foreach%22-with-annotation-tp28457518p28457518.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: Does anyone have any example of "foreach" with annotation

Posted by shamim <sr...@yandex.ru>.
Thank's very much for hints.

shamim wrote:
> 
> Hi All,
>   i have stuck with dynamic Sql on Ibatis 3 annotations. Trying to pass
> List in dynamic sql as follows:
> 
> @Update("update ${schemaName}.fuf uf" +
> 			" set uf.reestr_date = #{reestDate}," +
> 			" uf.reestr_number = #{reestNum}" +
> 			" where uf.reestr_number IS not NULL AND uf.reestr_date IS not NULL and
> uf.id in " +
> 			" <foreach item=\"item\" index=\"index\" collection=\"list\""+
> 			"	open=\"(\" separator=\",\" close=\")\">"+
> 			"	#{item}"+
> 			" </foreach>")
> 	void updateUpffReesterByList(@Param("schemaName") final String
> schemaName, @Param("list") List<Long> list, @Param("reestNum") final
> String reestNum, @Param("reestDate") final Date reestDate);
> 
> Its always throws JDBC exception. May be i am missing something?
> Thank'x in Advance
>   Shamim
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Does-anyone-have-any-example-of-%22foreach%22-with-annotation-tp28457518p28469337.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: Does anyone have any example of "foreach" with annotation

Posted by Clinton Begin <cl...@gmail.com>.
Perhaps with the shiny new SqlBuilder...  :-)

On 2010-05-05, Jeff Butler <je...@gmail.com> wrote:
> IIRC, iBATIS doesn't support dynamic SQL in annotations.  You'll need
> to use an @UpdateProvider and generate the dynamic SQL yourself.
>
> Jeff
>
> On Wed, May 5, 2010 at 2:18 AM, shamim <sr...@yandex.ru> wrote:
>>
>> Hi All,
>>  i have stuck with dynamic Sql on Ibatis 3 annotations. Trying to pass
>> List
>> in dynamic sql as follows:
>>
>> @Update("update ${schemaName}.fuf uf" +
>>                        " set uf.reestr_date = #{reestDate}," +
>>                        " uf.reestr_number = #{reestNum}" +
>>                        " where uf.reestr_number IS not NULL AND
>> uf.reestr_date IS not NULL and
>> uf.id in " +
>>                        " <foreach item=\"item\" index=\"index\"
>> collection=\"list\""+
>>                        "       open=\"(\" separator=\",\" close=\")\">"+
>>                        "       #{item}"+
>>                        " </foreach>")
>>        void updateUpffReesterByList(@Param("schemaName") final String
>> schemaName,
>> @Param("list") List<Long> list, @Param("reestNum") final String reestNum,
>> @Param("reestDate") final Date reestDate);
>>
>> Its always throws JDBC exception. May be i am missing something?
>> Thank'x in Advance
>>  Shamim
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Does-anyone-have-any-example-of-%22foreach%22-with-annotation-tp28457518p28457518.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
>
>

-- 
Sent from my mobile device

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


Re: Does anyone have any example of "foreach" with annotation

Posted by Jeff Butler <je...@gmail.com>.
IIRC, iBATIS doesn't support dynamic SQL in annotations.  You'll need
to use an @UpdateProvider and generate the dynamic SQL yourself.

Jeff

On Wed, May 5, 2010 at 2:18 AM, shamim <sr...@yandex.ru> wrote:
>
> Hi All,
>  i have stuck with dynamic Sql on Ibatis 3 annotations. Trying to pass List
> in dynamic sql as follows:
>
> @Update("update ${schemaName}.fuf uf" +
>                        " set uf.reestr_date = #{reestDate}," +
>                        " uf.reestr_number = #{reestNum}" +
>                        " where uf.reestr_number IS not NULL AND uf.reestr_date IS not NULL and
> uf.id in " +
>                        " <foreach item=\"item\" index=\"index\" collection=\"list\""+
>                        "       open=\"(\" separator=\",\" close=\")\">"+
>                        "       #{item}"+
>                        " </foreach>")
>        void updateUpffReesterByList(@Param("schemaName") final String schemaName,
> @Param("list") List<Long> list, @Param("reestNum") final String reestNum,
> @Param("reestDate") final Date reestDate);
>
> Its always throws JDBC exception. May be i am missing something?
> Thank'x in Advance
>  Shamim
>
>
> --
> View this message in context: http://old.nabble.com/Does-anyone-have-any-example-of-%22foreach%22-with-annotation-tp28457518p28457518.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