java中的批量导入,批量更新数据
批量插入 数据,提高效率
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中的批量导入,批量更新数据的更多相关文章
- java中,字符串类型的时间数据怎样转换成date类型。
将字符串类型的时间转换成date类型可以使用SimpleDateFormat来转换,具体方法如下:1.定义一个字符串类型的时间:2.创建一个SimpleDateFormat对象并设置格式:3.最后使用 ...
- [diango]批量导入不重复数据
去年研究导入数据的时候写了一个批量导入数据的脚本,但有个问题,如果导入这批数据在数据库中已经存在,那么我们导入的数据不就重复了么,本文就讨论如何解决这个问题? 程序如下: #coding:utf-8 ...
- hibernate批量删除和更新数据
转载自:http://blog.csdn.net/yuhua3272004/article/details/2909538 Hibernate3.0 採用新的基于ANTLR的HQL/SQL查询翻译器, ...
- mybatis 注解的方式批量插入,更新数据
一,当向数据表中插入一条数据时,一般先检查该数据是否已经存在,如果存在更新,不存在则新增 使用关键字 ON DUPLICATE KEY UPDATE zk_device_id为主键 model ...
- sequelize 批量添加和更新数据 bulkCreate
sequelize提供了批量插入数据的方法:Model.bulkCreate([…object]). 例如: let updatePhone = [{userName: '李白‘},{userNam ...
- SQL server 批量插入和更新数据
批量插入数据 insert into A表数据库名.[dbo].A(a,b,c) (select a,b,c from B表数据库名.[dbo].B) 批量更新数据 根据身份证第二位更新性别 upda ...
- java中使用poi导出excel表格数据并且可以手动修改导出路径
在我们开发项目中,很多时候会提出这样的需求:将前端的某某数据以excel表格导出,今天就给大家写一个简单的模板. 这里我们选择使用poi导出excel: 第一步:导入需要的jar包到 lib 文件夹下
- java 中Excel的导入导出
部分转发原作者https://www.cnblogs.com/qdhxhz/p/8137282.html雨点的名字 的内容 java代码中的导入导出 首先在d盘创建一个xlsx文件,然后再进行一系列 ...
- .Net中DataAdapter批量插入和更新数据总结
前言 前段时间一直在忙着项目上线,在做项目的同时遇到了一些之前不曾碰到的问题,因为没有经验,只能从网上找一些相关的解决方案,但是网上提供的资料实在是太杂,有的根本不能用,耗时又耗力. 我希望把我这段时 ...
- java中通过jacob调用dts进行数据导入导出
在一个项目中需要金蝶软件对接,但是业务服务器和财务服务器相隔很远(中间经过好几台服务器,有内网也有外网),从一个内网向另一个内网中传输时,需要外网辅助,因为不让原始数据受污染,使用了DTS数据同步到另 ...
随机推荐
- mac 命令整理
查看clang++搜索路径 clang++ -E -x c++ - -v < /dev/null
- Mac卡顿 CPU占100%的原因Photolibraryd
找到了造成电脑卡顿的元凶,第一步要做的就是杀进程,选中这两个进程,点击上面的结束按钮,世界立马恢复了宁静,高兴的继续码代码,可是好景不长,大约一个小时以后,又特么卡了,"任务管理器" ...
- kafak学习总结
高可用 多副本机制: 主副本和从副本,从副本只负责同步主副本数据,只有主副本进行读写. 高并发 网络结构设计 多路复用 多selector -> 多线程-> 多队列 高性能 写 把数据先写 ...
- NXOpen获取UFUN的tag
#include <NXOpen/NXObject.hxx>#include <NXOpen/NXObjectManager.hxx> 1 NXObject* nXObject ...
- C语言的qsort函数
C函数----qsort 函数 qsort()看起来和C++的sort()差不多,但是其实差别很大, qsort的cmp函数,传入的是指针,返回值是int sort的则传入值,返回值是bool 当qs ...
- php functions 生成唯一码
<?php /** * 微擎密码生成 * */ function we7password($passwordinput, $salt, $authkey) { $passwordinput = ...
- ES5中对象的继承
1.继承的类型 在oo语言中,继承有两种方式,借口继承和实现继承,因为ECMAScript不支持方法签名,所以ECMAScript只支持实现继承. 2.原型链继承的实现 2.1.原型链 ES5继承可以 ...
- uniapp引入微信小程序自定义视频组件--记录
官方文档:https://zh.uniapp.dcloud.io/tutorial/miniprogram-subject.html 在 pages.json同级目录下 创建目录和文件: wxcomp ...
- @Configuration 配置类打断点后,一启动项目读取到该配置类的话就会进断点
@Configuration 配置类的话,打断点的时候,一启动项目就会读取配置信息,然后你在@Configuration 配置的类中打断点的话,一启动项目就会读取配置类,然后就会进断点,跟你平常的co ...
- 控制台程序console输入参数 获取参数
class Program { static void Main(string[] args) { i ...