oracle和mysql mybatis批量更新

来源:互联网 发布:deepin linux卸载软件 编辑:程序博客网 时间:2024/06/15 04:36

oracle和mysql数据库的批量update在mybatis中配置不太一样:

转自地址http://my.oschina.net/jsonavaj/blog/265112?p={{currentPage+1}}

oracle数据库:

?
1
2
3
4
5
6
7
8
9
10
11
<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&amp;characterEncoding=UTF-8&allowMultiQueries=true

?
1
2
3
4
5
6
7
8
9
10
11
<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>

0 0
原创粉丝点击