oracle和mysql數據庫的批量update在mybatis中配置不太同樣:java
oracle數據庫:mysql
<update id="batchUpdate" parameterType="java.util.List"> <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數據庫:sql
mysql數據庫採用一下寫法便可執行,可是數據庫鏈接必須配置:&allowMultiQueries=true數據庫
例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=truemybatis
必定要加這個,否則抱錯,即便語句複製出來正確執行,系統仍是會抱錯oracle
<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>