oracle和mysql資料庫的批量update在mybatis中配置不太一樣:
oracle資料庫:
<updateid="batchUpdate" parameterType="java.util.List">
<foreach collection="list"item="item"index="index"open="begin"close="end;"separator=";">
updatetest
<set>
test=${item.test}+1
</set>
whereid = ${item.id}
</foreach>
</update>
mysql資料庫:
mysql資料庫采用一下寫法即可執行,但是資料庫連接配接必須配置:&allowMultiQueries=true
例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
<updateid="batchUpdate" parameterType="java.util.List">
<foreach collection="list"item="item"index="index"open=""close=""separator=";">
updatetest
<set>
test=${item.test}+1
</set>
whereid = ${item.id}
</foreach>
</update>