mybaitis批量操做時mysql和orcle數據庫的配置

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&amp;characterEncoding=UTF-8&allowMultiQueries=true  mybatis

<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>
相關文章
相關標籤/搜索