void updateFndContainerItems(List<Long> list);
<update id="updateFndContainerItems">
update fnd_container_item set delete_flag = 1 where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
报错信息:
Query is: update fnd_container_item set delete_flag = 1 where id in
(
?
,
?
,
?
), parameters [1,2,3]
at org.mariadb.jdbc.internal.util.LogQueryTool.exceptionWithQuery(LogQueryTool.java:153) ~[mariadb-java-client-2.2.4.jar:na]
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:254) ~[mariadb-java-client-2.2.4.jar:na]
at org.mariadb.jdbc.MariaDbPreparedStatementClient.executeInternal(MariaDbPreparedStatementClient.java:209) ~[mariadb-java-client-2.2.4.jar:na]
... 121 common frames omitted
拿到打印的sql和参数,在Navicat中执行报错:
去掉空格后是ok的:
为什么呢?
---------------------------------------------------------------------------------------
最后改为参数的类型是Array,则在使用时,collection属性要必须指定为 array
updateFndContainerItemsByIds(Long[] ids);
<update id="updateFndContainerItemsByIds">
update fnd_container_item set delete_flag = 1 where id in
<foreach item="item" index="index" collection="array"
open="(" separator="," close=")">
#{item}
</foreach>
</update>