mysql 默认不支持批量更新,要实现批量更新,需设置 mysql 支持批量操作,在 jdbc 链接中加上 &allowMultiQueries=true 就可以了
批量更新sql
<update id="batchUpdate">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update table1
<set> `col1` = #{value1},
`col2` = #{value2}
</set>
where `id` = #{id}
</foreach>
</update>