MyBatis + Oracle 实现批量新增(基于序列化自增长主键)

mapper 接口

 void batchInsert(List<ASingleProject> list); 

mapper.xml

<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">insert into A_SINGLE_PROJECT (KID, SINGLEPROJECTID, ZJZMJ, DSGD, DSCS, DXCS, JGLX, JCXS, DS_JZMJ, JKC_JZMJ, DX_JZMJ, ZZ_JZMJ, BG_JZMJ, SY_JZMJ, CF_JZMJ, RF_JZMJ, QT_YFMJ, DSGYTS, TS_60_100, TS_100_144, TS_144, TS_BS, ZTS, JGZDKD, HS, XSDTS, KCFTS) select s_a_single_project.nextval, cd.* from (<foreach collection="list" item="item" index="index" separator="UNION ALL" >(select #{item.singleprojectid,jdbcType=DECIMAL}, #{item.zjzmj,jdbcType=VARCHAR}, #{item.dsgd,jdbcType=VARCHAR}, #{item.dscs,jdbcType=VARCHAR}, #{item.dxcs,jdbcType=VARCHAR}, #{item.jglx,jdbcType=VARCHAR}, #{item.jcxs,jdbcType=VARCHAR}, #{item.dsJzmj,jdbcType=VARCHAR}, #{item.jkcJzmj,jdbcType=VARCHAR}, #{item.dxJzmj,jdbcType=VARCHAR}, #{item.zzJzmj,jdbcType=VARCHAR}, #{item.bgJzmj,jdbcType=VARCHAR}, #{item.syJzmj,jdbcType=VARCHAR}, #{item.cfJzmj,jdbcType=VARCHAR}, #{item.rfJzmj,jdbcType=VARCHAR}, #{item.qtYfmj,jdbcType=VARCHAR}, #{item.dsgyts,jdbcType=VARCHAR}, #{item.ts60100,jdbcType=VARCHAR}, #{item.ts100144,jdbcType=VARCHAR}, #{item.ts144,jdbcType=VARCHAR}, #{item.tsBs,jdbcType=VARCHAR}, #{item.zts,jdbcType=VARCHAR}, #{item.jgzdkd,jdbcType=VARCHAR}, #{item.hs,jdbcType=VARCHAR}, #{item.xsdts,jdbcType=VARCHAR}, #{item.kcfts,jdbcType=VARCHAR}from dual)</foreach>) cd</insert>

MyBatis + Oracle 实现批量修改

mapper 接口

void batchUpdate(List<ASingleProject> list); 

mapper.xml

 <update id="batchUpdate" parameterType="java.util.List"><foreach collection="list" index="index" item="item" open="begin" close=";end;" separator=";">update A_SINGLE_PROJECT<set><if test="item.zjzmj != null">ZJZMJ = #{item.zjzmj,jdbcType=VARCHAR},</if><if test="item.dsgd != null">DSGD = #{item.dsgd,jdbcType=VARCHAR},</if><if test="item.dscs != null">DSCS = #{item.dscs,jdbcType=VARCHAR},</if><if test="item.dxcs != null">DXCS = #{item.dxcs,jdbcType=VARCHAR},</if><if test="item.jglx != null">JGLX = #{item.jglx,jdbcType=VARCHAR},</if><if test="item.jcxs != null">JCXS = #{item.jcxs,jdbcType=VARCHAR},</if><if test="item.dsJzmj != null">DS_JZMJ = #{item.dsJzmj,jdbcType=VARCHAR},</if><if test="item.jkcJzmj != null">JKC_JZMJ = #{item.jkcJzmj,jdbcType=VARCHAR},</if><if test="item.dxJzmj != null">DX_JZMJ = #{item.dxJzmj,jdbcType=VARCHAR},</if><if test="item.zzJzmj != null">ZZ_JZMJ = #{item.zzJzmj,jdbcType=VARCHAR},</if><if test="item.bgJzmj != null">BG_JZMJ = #{item.bgJzmj,jdbcType=VARCHAR},</if><if test="item.syJzmj != null">SY_JZMJ = #{item.syJzmj,jdbcType=VARCHAR},</if><if test="item.cfJzmj != null">CF_JZMJ = #{item.cfJzmj,jdbcType=VARCHAR},</if><if test="item.rfJzmj != null">RF_JZMJ = #{item.rfJzmj,jdbcType=VARCHAR},</if><if test="item.qtYfmj != null">QT_YFMJ = #{item.qtYfmj,jdbcType=VARCHAR},</if><if test="item.dsgyts != null">DSGYTS = #{item.dsgyts,jdbcType=VARCHAR},</if><if test="item.ts60100 != null">TS_60_100 = #{item.ts60100,jdbcType=VARCHAR},</if><if test="item.ts100144 != null">TS_100_144 = #{item.ts100144,jdbcType=VARCHAR},</if><if test="item.ts144 != null">TS_144 = #{item.ts144,jdbcType=VARCHAR},</if><if test="item.tsBs != null">TS_BS = #{item.tsBs,jdbcType=VARCHAR},</if><if test="item.zts != null">ZTS = #{item.zts,jdbcType=VARCHAR},</if><if test="item.jgzdkd != null">JGZDKD = #{item.jgzdkd,jdbcType=VARCHAR},</if><if test="item.hs != null">HS = #{item.hs,jdbcType=VARCHAR},</if><if test="item.xsdts != null">XSDTS = #{item.xsdts,jdbcType=VARCHAR},</if><if test="item.kcfts != null">KCFTS = #{item.kcfts,jdbcType=VARCHAR},</if></set>where  SINGLEPROJECTID = #{item.singleprojectid,jdbcType=DECIMAL}</foreach></update>

MyBatis + Oracle 实现批量新增和批量修改相关推荐

  1. Mybatis-plugs 批量新增及批量修改、IN、CASE WHEN操作

    1.1 基本介绍 Mybatis-plugs 批量新增及批量修改.IN.CASE WHEN 查询,简单,适用,最近用到了,那就留下点痕迹,免得下次用到再去找 <foreach> 标签里面的 ...

  2. mybatis批量新增和批量更新的效率对比

    今天,为了更多了解下,mybatis批量新增和批量更新在simple/batch模式 + MySQL的rewriteBatchedStatements下效率有什么区别,做了一次实验. 实验结果,让人意 ...

  3. Mybatis Plus重写批量新增和批量删除

    批量新增: import com.baomidou.mybatisplus.core.injector.AbstractMethod; import com.baomidou.mybatisplus. ...

  4. orcal 批量新增,批量更新多条件

    批量新增 <insert id="savePatientEmr" parameterType="java.util.List" useGeneratedK ...

  5. mysql不存在就批量新增_mysql批量插入,存在则修改,不存在则插入

    批量插入,存在则修改,不存在则插入 INSERT INTO 表名 (字段1,字段2,字段3,字段4) VALUES (字段1值,字段2值,字段3值,字段4值) ON DUPLICATE KEY UPD ...

  6. JAVA 之POI导入批量新增、批量检查、日志记录、失败原因、失败条数、数据库映射

    前言 欢迎大家来到我的博客,请各位看客们点赞.收藏.关注三连! 欢迎大家关注我的知识库,Java之从零开始·语雀 你的关注就是我前进的动力! CSDN专注于问题解决的博客记录,语雀专注于知识的收集与汇 ...

  7. mybatis mysql 批量更新_mysql批量update更新,mybatis中批量更新操作

    在日常开发中,有时候会遇到批量更新操作,这时候最普通的写法就是循环遍历,然后一条一条地进行update操作.但是不管是在服务端进行遍历,还是在sql代码中进行遍历,都很耗费资源,而且性能比较差,容易造 ...

  8. mybatis-plus的批量新增/批量更新以及问题

    批量新增/删除 1.代码中foreach insert/update 2.多线程foreach insert/update 3.mybatis xml中foreach 4.通过自定义 SQL注入器扩展 ...

  9. 基于ruoyi+vue+elementUI实现列表,新增,附件上传,tab+springBoot+mybatis+oracle序列+批量新增

    基于ruoyi+vue+elementUI实现列表,新增,附件上传,tab+springBoot+mybatis+oracle序列+批量新增 页面效果 列表页面 新增页面 详情页面 代码实现 列表+新 ...

最新文章

  1. python中的单例模式
  2. UVa 10652 (简单凸包) Board Wrapping
  3. depcomp: line 571: exec: g++: not found
  4. 对linux做一个简单介绍,对“Fork”做一个技术方面的简介
  5. [Java基础]线程安全的类
  6. 日照职业技术学院计算机怎么样,日照职业技术学院宿舍条件怎么样 住宿环境好不好...
  7. dataframe 上下拼接_pandas DataFrame 的横向纵向拼接组合
  8. 计算机网络基础系列(三)网络应用
  9. iOS自定义SearchBar样式
  10. 【滤波器设计】基于matlab GUI窗函数法高通+低通+带通带阻FIR滤波器设计【含Matlab源码 072期】
  11. C++里大写TRUE和小写true(BOOL与bool)
  12. CUDA版本与显卡驱动匹配
  13. win7系统设置cmd窗口默认以管理员权限运行
  14. 警惕!!类似的QQ诈骗手段层出不穷
  15. 如何在Vue中使用lottie加载SVG动画
  16. CCS中调试DM6467高清视频采集(TVP7002输入)
  17. Unity打包webgl文本框不显示汉字
  18. 利用Unity引擎C#语言实现MySql数据库读写
  19. Spring Cloud Gateway 不小心换了个 Web 容器就不能用了,我 TM 人傻了
  20. 1w存银行一年多少利息_100万存在银行,一年最高能有多少利息?

热门文章

  1. 从理论到实践落地「微服务
  2. 工业机器人应用与选型知多少?
  3. Tessent Ijtag 第二章节 什么是ICL文件
  4. positive-unlabeled (PU) learning
  5. 【学习笔记】consul注册中心,服务注册、服务发现、服务监控笔记
  6. Android提权漏洞CVE-2014-7920、CVE-2014-7921
  7. How to Read a Book: Chapter one The Activity and Art of Rading
  8. 888道Java高级面试题,JDK、JRE与JVM的区别与联系
  9. 2023节日营销趋势报告
  10. 网红、科技大佬、作家,跨界喜剧王罗永浩才是打造个人IP的典范