打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
mybatis执行批量更新batch update 的方法(oracle,mysql)

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>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
mybatis批量操作
Mybatis中,当插入数据后,返回最新主键id的几种方法,及具体用法
Hibernate、Mybatis 数据库连接字符串
Mybatis之批量更新操作
Mybatis中进行批量更新(updateBatch)
Mybatis 批量插入数据 关于Oracle 批量插入报错:ORA-00933: SQL 命令未正确结束
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服