批量插入 数据,提高效率

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. python查找文件、移动、重命名、压缩

    在文件同级目录下存在sourcefile.targetfile两个文件夹,源文件放在sourcefile import os import shutil Apath = os.path.dirname ...

  2. js 数字千元符号分割

    /* * 参数说明:* number:要格式化的数字* decimals:保留几位小数 * dec_point:小数点符号* thousands_sep:千分位符号* */export functio ...

  3. Gitlab迁移(亲测)

    1. 概述 当前gitlab部署在k8s内,根据基础设施设计此处不合理,需将gitlab迁移至主机部署的gitlab 当前位置:k8s 集群 迁移后位置:云主机部署gitlab 2. Gitlab从K ...

  4. HIVE- lag函数和lead函数

    select date_flag,category_flag,field,LAG(filed, 1) OVER (PARTITION BY category_flag ORDER BY date_fl ...

  5. Spring 自定义注解 操作日志

    1.自定义注解 package com.jay.demo3.aop1.myannotation;       import java.lang.annotation.Documented;   imp ...

  6. 快速傅里叶变换详解(FFT)

    自己也看了几篇博客,但是对我这种不擅长推导小白来说还是有一点困难,所以自己也写一篇博客也为像我一样的小白提供思路.以下内容包含各种LaTeX渲染,如果哪里有错误欢迎大家评论留言,或者添加本人qq:14 ...

  7. windows安装和重装系统后无法识别U盘

    安装系统的方法: 1. 方案一,用大白菜制写入pe系统,但必须先准备Windows安装包 方案二,把ISO格式的系统安装包直接写入到u盘,写入U盘的方法请百度 2.开机看到电脑的logo后,按f2(不 ...

  8. WIN10操作系统如何利用无线网卡连接wifi再通过有线网卡共享网络给路由(双网卡)

    首先有一台笔记本电脑,或者双网卡的电脑(wifi网卡 和 有线网卡) 找到两个个网卡,并重置他们的设置 然后同时选中,右单击选择桥接 桥接成功以后就可以用无线网卡连接wifi,然后把有线网口插上网线直 ...

  9. JAVA框架知识

    Java中的MVC: M是指模型层,C则是控制器,V是指视图:一个完整的请求过程是,客户端发送请求到控制器,控制器调用业务层处理请求,并返回处理结果给视图,其中业务层是调用Dao层去完成业务逻辑的:M ...

  10. Scoped方法(防止样式名称冲突)

    App.vue <template> <div> <Student/> <School></School> </div> < ...