Mybatis批量更新数据
2016-07-23 03:08
405 查看
Mybatis批量更新数据
第一种方式[html] view plain copy
print?
<update id="updateBatch" parameterType="Map">
update aa set
a=#{fptm},
b=#{csoftrain}
where c in
<foreach collection="cs" index="index" item="item" open="("separator=","close=")">
#{item}
</foreach>
</update>
但是这种方式修改的字段值都是一样的。
第二种方式
修改数据库连接配置:&allowMultiQueries=true
比如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
[html] view plain copy
print?
<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>
这种方式,可以一次执行多条SQL语句
摘录自:http://blog.csdn.net/tolcf/article/details/39213217
相关文章推荐
- 系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
- cocos2dx实现简单卡牌翻转效果
- 《App研发录》知识点汇总
- 解决编译apache出现的问题:configure: error: APR not found . Please read the documentation
- Spring+MyBatis多数据源配置实现
- Power of Two & Power of Three & Power of Four
- 优雅的懒加载方法
- window消息处理模块
- Regular Expression Matching & Wildcard Matching
- 给自己技术发展之路上的意见
- mybatis_SQL映射(2)
- 守护进程详细解读
- 大数计算
- 安装vs2013的entityframework
- 2016 Multi-University Training Contest 1 -1006 PowMod
- 串口通信的基本概念
- SparseArray解析
- php基础和http知识介绍
- 插件框架篇之Activity中theme、launchMode等设置问题
- if else