转至:http://www.jb51.cc/article/p-qfmzocje-boy.html
http://www.jb51.cc/article/p-aejbjcud-qt.html
oracle和MysqL数据库的批量update在mybatis中配置不太一样:
oracle数据库:
<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";"> update test <set> test=${item.test}+1 </set> where id = ${item.id} </foreach> </update>
MysqL数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true
例如:jdbc:MysqL://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
<foreach collection="list" item="item" index="index" open="" close="" separator=";"> update test <set> test=${item.test}+1 </set> where id = ${item.id} </foreach> </update>
通用: update aa set a=#{fptm},b=#{csoftrain} where c in #{item}