首页 > 基础资料 博客日记
java中的批量导入,批量更新数据
2023-07-24 18:36:00基础资料围观226次
文章java中的批量导入,批量更新数据分享给大家,欢迎收藏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>
文章来源:https://www.cnblogs.com/xingmeng63/p/16493271.html
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签: