如存在问题 或有更好建议 请联系 作者QQ:2940500
记录坑:
注意: 在使用批量更新之前 要先设置 mysql 支持 批量执行多条sql 在连接信息后加上[&allowMultiQueries=true]
mybatis sql如下:
<update id="updateList">
<foreach separator=";" index="index" item="item" collection="list" close="" open="">
update tb_activity
set status=${item.status}
where id = ${item.id}
</foreach>
</update>
当然还有另外一种批量修改需求:
<update id="batchUpdate1" parameterType="java.util.List">
update sys_group set level = null where level in
<foreach separator="," index="index" item="item" collection="list" close=")" open="(">
#{item}
</foreach>
</update>