参考:http://blog.csdn.net/tolcf/article/details/39213217#
批量修改的二种方式
第一种方式
<update id="updateBatch" parameterType="Map">
update aa set
a=#{fptm},
b=#{csoftrain}
where c in
<foreach collection="cs" index="index" item="item" pen="("separator=","close=")">
#{item}
</foreach>
</update>
第二种方式
批量修改 需要多条sql语句同时执行,通过separator=";" 分号分割 则需要修改数据库连接配置:
添加allowMultiQueries 关键字给定初始值 true (及在数据库连接配置后 加上 &allowMultiQueries=true)
比如:jdbc:MySQL://ip:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update test
<set>
test=${item.test}+1
</set>
where id = ${item.id}
</foreach>
</update>