MyBatis批量修改操作
Posted 张什么锋
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatis批量修改操作相关的知识,希望对你有一定的参考价值。
首先 这编博客经本人试用过,与理想效果一致
.MyBatis配置
这是mysql的配置,注意需要加上&allowMultiQueries=true配置
jdbc_url=jdbc:mysql://localhost:3306/go?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
‘&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true‘ 是重点!之前就是因为这个一直没有成功。。。。
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update channels
<set>
state=${item.state}
</set>
where id = ${item.id}
</foreach>
</update>
oracle和mysql的配置不一样
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
update channels
<set>
state=${item.state}
</set>
where id = ${item.id}
</foreach>
</update>
Mysql的配置在实际运用中成功了,Oracle的没有试过
详情 参考 至 https://my.oschina.net/jsonavaj/blog/265112
以上是关于MyBatis批量修改操作的主要内容,如果未能解决你的问题,请参考以下文章
mybatis 调用存储过程进行批量修改操作(只需要一次调用存储过程),不知道如何配置配置文件
javamybatis在使用mybatis进行批量插入,批量更新等批量操作时,切割In集合List进行分批批量操作的java中的切割代码