批量插入 数据,提高效率

Dao层

int insertBatch(List<HealthImport> list);

 

xml文件

<insert id="insertBatch" parameterType="java.util.List" >
insert into health_import
(answer_id, sample_num, `name`,
sex, age, select_goal,
pro_id, pro_name, select_result,
sample, patient_id, barcode,
reviewer, idcard, refer_range,
unit, create_time, `result`,
flag, message)
values
<foreach collection="list" index="index" item="monitor" separator=",">
(#{monitor.answerId,jdbcType=INTEGER}, #{monitor.sampleNum,jdbcType=VARCHAR}, #{monitor.name,jdbcType=VARCHAR},
#{monitor.sex,jdbcType=VARCHAR}, #{monitor.age,jdbcType=VARCHAR}, #{monitor.selectGoal,jdbcType=VARCHAR},
#{monitor.proId,jdbcType=VARCHAR}, #{monitor.proName,jdbcType=VARCHAR}, #{monitor.selectResult,jdbcType=VARCHAR},
#{monitor.sample,jdbcType=VARCHAR}, #{monitor.patientId,jdbcType=VARCHAR}, #{monitor.barcode,jdbcType=VARCHAR},
#{monitor.reviewer,jdbcType=VARCHAR}, #{monitor.idcard,jdbcType=VARCHAR}, #{monitor.referRange,jdbcType=VARCHAR},
#{monitor.unit,jdbcType=VARCHAR}, #{monitor.createTime,jdbcType=TIMESTAMP}, #{monitor.result,jdbcType=INTEGER},
#{monitor.flag,jdbcType=INTEGER}, #{monitor.message,jdbcType=VARCHAR})
</foreach>
</insert>

  

批量 更新数据 提高效率

Dao层

int updateBatch(List<HealthImport> list);

  

xml文件

<update id="updateBatch" parameterType="java.util.List" >
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update health_import
<set>
<if test="item.answerId != null">
answer_id = #{item.answerId,jdbcType=INTEGER},
</if>
<if test="item.sampleNum != null">
sample_num = #{item.sampleNum,jdbcType=VARCHAR},
</if>
<if test="item.name != null">
`name` = #{item.name,jdbcType=VARCHAR},
</if>
<if test="item.sex != null">
sex = #{item.sex,jdbcType=VARCHAR},
</if>
<if test="item.age != null">
age = #{item.age,jdbcType=VARCHAR},
</if>
<if test="item.selectGoal != null">
select_goal = #{item.selectGoal,jdbcType=VARCHAR},
</if>
<if test="item.proId != null">
pro_id = #{item.proId,jdbcType=VARCHAR},
</if>
<if test="item.proName != null">
pro_name = #{item.proName,jdbcType=VARCHAR},
</if>
<if test="item.selectResult != null">
select_result = #{item.selectResult,jdbcType=VARCHAR},
</if>
<if test="item.sample != null">
sample = #{item.sample,jdbcType=VARCHAR},
</if>
<if test="item.patientId != null">
patient_id = #{item.patientId,jdbcType=VARCHAR},
</if>
<if test="item.barcode != null">
barcode = #{item.barcode,jdbcType=VARCHAR},
</if>
<if test="item.reviewer != null">
reviewer = #{item.reviewer,jdbcType=VARCHAR},
</if>
<if test="item.idcard != null">
idCard = #{item.idcard,jdbcType=VARCHAR},
</if>
<if test="item.referRange != null">
refer_range = #{item.referRange,jdbcType=VARCHAR},
</if>
<if test="item.unit != null">
unit = #{item.unit,jdbcType=VARCHAR},
</if>
<if test="item.createTime != null">
create_time = #{item.createTime,jdbcType=TIMESTAMP},
</if>
<if test="item.result != null">
`result` = #{item.result,jdbcType=INTEGER},
</if>
<if test="item.flag != null">
flag = #{item.flag,jdbcType=INTEGER},
</if>
<if test="item.message != null">
message = #{item.message,jdbcType=INTEGER}
</if>
</set>
where pro_id = #{item.proId,jdbcType=VARCHAR} and sample_num = #{item.sampleNum,jdbcType=VARCHAR}
</foreach>
</update>

  

 

java中的批量导入,批量更新数据的更多相关文章

  1. java中,字符串类型的时间数据怎样转换成date类型。

    将字符串类型的时间转换成date类型可以使用SimpleDateFormat来转换,具体方法如下:1.定义一个字符串类型的时间:2.创建一个SimpleDateFormat对象并设置格式:3.最后使用 ...

  2. [diango]批量导入不重复数据

    去年研究导入数据的时候写了一个批量导入数据的脚本,但有个问题,如果导入这批数据在数据库中已经存在,那么我们导入的数据不就重复了么,本文就讨论如何解决这个问题? 程序如下: #coding:utf-8 ...

  3. hibernate批量删除和更新数据

    转载自:http://blog.csdn.net/yuhua3272004/article/details/2909538 Hibernate3.0 採用新的基于ANTLR的HQL/SQL查询翻译器, ...

  4. mybatis 注解的方式批量插入,更新数据

    一,当向数据表中插入一条数据时,一般先检查该数据是否已经存在,如果存在更新,不存在则新增  使用关键字  ON DUPLICATE KEY UPDATE zk_device_id为主键 model  ...

  5. sequelize 批量添加和更新数据 bulkCreate

    sequelize提供了批量插入数据的方法:Model.bulkCreate([…object]). 例如: let  updatePhone = [{userName: '李白‘},{userNam ...

  6. SQL server 批量插入和更新数据

    批量插入数据 insert into A表数据库名.[dbo].A(a,b,c) (select a,b,c from B表数据库名.[dbo].B) 批量更新数据 根据身份证第二位更新性别 upda ...

  7. java中使用poi导出excel表格数据并且可以手动修改导出路径

    在我们开发项目中,很多时候会提出这样的需求:将前端的某某数据以excel表格导出,今天就给大家写一个简单的模板. 这里我们选择使用poi导出excel: 第一步:导入需要的jar包到 lib 文件夹下

  8. java 中Excel的导入导出

    部分转发原作者https://www.cnblogs.com/qdhxhz/p/8137282.html雨点的名字  的内容 java代码中的导入导出 首先在d盘创建一个xlsx文件,然后再进行一系列 ...

  9. .Net中DataAdapter批量插入和更新数据总结

    前言 前段时间一直在忙着项目上线,在做项目的同时遇到了一些之前不曾碰到的问题,因为没有经验,只能从网上找一些相关的解决方案,但是网上提供的资料实在是太杂,有的根本不能用,耗时又耗力. 我希望把我这段时 ...

  10. java中通过jacob调用dts进行数据导入导出

    在一个项目中需要金蝶软件对接,但是业务服务器和财务服务器相隔很远(中间经过好几台服务器,有内网也有外网),从一个内网向另一个内网中传输时,需要外网辅助,因为不让原始数据受污染,使用了DTS数据同步到另 ...

随机推荐

  1. canvas 学习笔记

    1.利用上下文对象进行绘制画笔 var canvas=canvas.getContext('2d') 2.绘制路径 canvas.rect(30,30,300,300) 3.填充 canvas.fil ...

  2. python + QML程序中调用WebView后打包

    QML中如果加入了WebView控件,在用pyinstaller打包时不会自动导入,从而导致打包出的程序运行报错,no WebView plugin found,此时需要手动将WebView控件复制到 ...

  3. python接口测试常见问题。

    一.入参问题 1.body字段类型 1.如果数据是从excel提取的那么中文数据会提示错误. 解决方法# media_value['body'] = media_value['body'].encod ...

  4. Excel条件格式的应用

    一.突出单元格规则 大于/小于/等于/包含/发生日期/重复值 发生日期(自定义)通常通过辅助单元格进行:选中单元格区域,条件格式-新建规则-选择规则类型(使用公式确定要设置的单元格),设置内容如下 二 ...

  5. C# 生成二维码方法(QRCoder)

    前言 二维码很多地方都有使用到.如果是静态的二维码还是比较好处理的,通过在线工具就可以直接生成一张二维码图片,比如:草料二维码. 但有的时候是需要动态生成的(根据动态数据生成),这个使用在线就工具就无 ...

  6. Docker CLI docker build 常用命令

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows操作系统的机器上,也可以实现虚拟化.Docker是内核 ...

  7. ctfshow web入门 命令执行 37-39

    37-39 基于 GET 传参的 include() 38.39 是 37 的变种 分析 伪协议常用于文件包含漏洞中 文件包含函数有:include.include_once.require.requ ...

  8. CH583 是集成 BLE 无线通讯的 RISC-V MCU 微控制器

    CH583 是集成 BLE 无线通讯的 RISC-V MCU 微控制器.片上集成 2Mbps 低功耗蓝牙 BLE 通讯模块.2 个全速 USB 主机和设备控制器及收发器.2 个 SPI.4 个串口.1 ...

  9. 2022强网拟态 WHOYOUARE

    2022强网拟态 WHOYOUARE 先说一下这个思路 由于禁用了__proto__所以我们可以通过constructor.prototype来绕过 之前一直不明白为什么是这样绕过的后来仔细研究了一下 ...

  10. 并发多线程学习(五)Java线程的状态及主要转化方法

    1 操作系统中的线程状态转换 首先我们来看看操作系统中的线程状态转换. 在现在的操作系统中,线程是被视为轻量级进程的,所以操作系统线程的状态其实和操作系统进程的状态是一致的. 操作系统线程主要有以下三 ...