MyBatis常用批量方法
<!-- 批量添加派车单子表数据 -->
<insert id="addBatch" parameterType="java.util.List" >
insert into hylm_shipment_item
(
ship_number,
order_number,
pre_number,
goods_id,
real_num,
real_weight,
real_cubage,
cost,
creater,
createDate,
finalOperator,
operatTime,
pId,
uId,
orgId,
roleId
)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.shipnumber,jdbcType=VARCHAR},
#{item.ordernumber,jdbcType=VARCHAR},
#{item.prenumber,jdbcType=VARCHAR},
#{item.goodsid,jdbcType=FLOAT},
#{item.realnum,jdbcType=VARCHAR},
#{item.realweight,jdbcType=VARCHAR},
#{item.realcubage,jdbcType=VARCHAR},
#{item.cost,jdbcType=VARCHAR},
#{item.creater,jdbcType=VARCHAR},
#{item.createDate,jdbcType=VARCHAR},
#{item.finalOperator,jdbcType=VARCHAR},
#{item.operatTime,jdbcType=VARCHAR},
#{item.pId,jdbcType=VARCHAR},
#{item.uId,jdbcType=VARCHAR},
#{item.orgId,jdbcType=VARCHAR},
#{item.roleId,jdbcType=VARCHAR}
)
</foreach>
</insert> <!-- 批量删除中转地数据 -->
<delete id = "deleteBatch" parameterType = "java.util.List">
<![CDATA[
delete from hylm_shipment_item where id in
]]>
<foreach collection="list" item="model" open="(" separator="," close=")">
#{model.id}
</foreach>
</delete> <!-- 批量更新派车单子表数据 -->
<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator=";">
update hylm_shipment_item
<trim prefix="set" prefixOverrides=",">
<if test="item.id != null and item.id != ''">
,id = #{item.id}
</if>
<if test="item.shipnumber != null and item.shipnumber != ''">
,ship_number = #{item.shipnumber}
</if>
<if test="item.ordernumber != null and item.ordernumber != ''">
,order_number = #{item.ordernumber}
</if>
<if test="item.prenumber != null and item.prenumber != ''">
,pre_number = #{item.prenumber}
</if>
<if test="item.goodsid != null and item.goodsid != ''">
,goods_id = #{item.goodsid}
</if>
<if test="item.realnum != null and item.realnum != ''">
,real_num = #{item.realnum}
</if>
<if test="item.realweight != null and item.realweight != ''">
,real_weight = #{item.realweight}
</if>
<if test="item.realcubage != null and item.realcubage != ''">
,real_cubage = #{item.realcubage}
</if>
<if test="item.cost != null and item.cost != ''">
,cost = #{item.cost}
</if>
<if test="item.creater != null and item.creater != ''">
,creater = #{item.creater}
</if>
<if test="item.createDate != null and item.createDate != ''">
,createDate = #{item.createDate}
</if>
<if test="item.finalOperator != null and item.finalOperator != ''">
,finalOperator = #{item.finalOperator}
</if>
<if test="item.operatTime != null and item.operatTime != ''">
,operatTime = #{item.operatTime}
</if>
<if test="item.pId != null">
,pId = #{item.pId,jdbcType=VARCHAR}
</if>
<if test="item.uId != null">
,uId = #{item.uId,jdbcType=VARCHAR}
</if>
<if test="item.orgId != null">
,orgId = #{item.orgId,jdbcType=VARCHAR}
</if>
<if test="item.roleId != null">
,roleId = #{item.roleId,jdbcType=VARCHAR}
</if>
</trim>
where 1 = 1
<if test="item.id != null and item.id != ''">
and id = #{item.id}
</if>
<if test="item.ordernumber != null and item.ordernumber != ''">
and order_number = #{item.ordernumber}
</if>
<if test="item.uId != null and item.uId != ''">
and uId = #{item.uId}
</if>
</foreach>
</update>
MyBatis常用批量方法的更多相关文章
- Mybatis 实现批量插入和批量删除源码实例
Mybatis 实现批量插入数据和批量删除数据 学习内容: 准备工作 1.数据库新建表 2.新建 Maven 项目和设置编译版本及添加依赖 3.新建 db.properties 4.新建 mybati ...
- mybatis执行批量更新update
Mybatis的批量插入这里有http://ljhzzyx.blog.163.com/blog/static/38380312201353536375/.目前想批量更新,如果update的值是相同的话 ...
- 161102、MyBatis中批量插入
方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...
- Elasticsearch java api 常用查询方法QueryBuilder构造举例
转载:http://m.blog.csdn.net/u012546526/article/details/74184769 Elasticsearch java api 常用查询方法QueryBuil ...
- Mybatis+mysql批量插入性能分析测试
前言 今天在网上看到一篇文章(后文中的文章指的就是它) https://www.jianshu.com/p/cce617be9f9e 发现了一种有关于mybatis批量插入的新方法,而且看了文章发现我 ...
- Mybatis 常用注解
Mybatis常用注解对应的目标和标签如表所示: 注解 目标 对应的XML标签 @CacheNamespace 类 <cache> @CacheNamespaceRef 类 <cac ...
- ETL流程介绍及常用实现方法
ETL是英文Extract-Transform-Load 的缩写,用来描述将数据从来源端经过抽取(extract).转换(transform).加载(load)至目的端的过程.常见于数据仓库开发中将数 ...
- mysql基础---->mybatis的批量插入(一)
这里面记录一下使用mybatis处理mysql的批量插入的问题,测试有可能不准.只愿世间风景千般万般熙攘过后,字里行间,人我两忘,相对无言. mybatis的批量插入 我们的测试主体类是springb ...
- 170829、mybatis使用oracle和mybatis中批量更新
一.mybatis执行批量更新batch update 的方法(mysql数据库) 1.数据库连接必须配置:&allowMultiQueries=true(切记一定要加上这个属性,否则会有问题 ...
随机推荐
- 02-Java中的锁详解
I. 使用Lock接口 只要不涉及到复杂用法,一般采用的是Java的synchronized机制 不过,Lock可以提供一些synchronized不支持的机制 非阻塞的获取锁:尝试获取锁,如果能获取 ...
- Mysql教程:(四)连接查询
连接查询 1.左连接查询: mysql> select stu.*,sc.*,maths+sc.chinese+sc.english from student stu left join sco ...
- map2bean & bean2map
1,自己实现: /** * @author xx * @since 2020/7/8 */ @Slf4j public class JavaBeanUtils { /** * 实体类转map * 效率 ...
- Android Thermal HAL 降龙十八掌
基本概念 参阅下面两篇文章,就可以大概了解一些概念的内容了 https://source.android.com/devices/architecture/hidl/thermal-mitigatio ...
- 树莓派4b安装Ubuntu20.04
树莓派4b安装Ubuntu20.04 下载Ubuntu20.04镜像 下载地址 安装Raspberry Pi Imager 下载地址 烧录系统 打开Raspberry Pi Imager,选择自己刚刚 ...
- Python 练习 人事管理
人事管理系统介绍:1.展示页面: ①首页: ==========欢迎来到简历管理系统v2.1.1========== 1.管理员登录 ...
- InnoDB 索引详解
1.什么是索引 索引是存储引擎用于快速找到记录的一种数据结构. 2.索引有哪些数据结构 顺序查找结构:这种查找效率很低,复杂度为O(n).大数据量的时候查询效率很低. 有序的数据排列:二分查找法又称折 ...
- [atARC096F]Sweet Alchemy
给定一棵有根树,记$f_{i}$表示$i$的父亲,每一个点有一个代价$c_{i}$ 给定常数$D$和$X$,再给每个点赋一个权值$v_{i}$($v_{i}\ge 0$),满足以下条件下最大化$\su ...
- [loj3367]装饼干
先考虑如何判定一个$y$是否可行--从高位开始,记录这一位所需要的$2^{i}$数量$t$,若$y$的这一位为1,则$t+=x$,之后分两类讨论:1.$t\le a_{i}$,令$t=0$:2.$b& ...
- [loj3176]景点划分
不妨设$a\le b\le c$,那么相当于要找到两个大小至少为$a$和$b$的连通块(连通块可以通过删除度最小的点变小) 以一个点为根建出dfs树并对以下情况分类讨论: 1.存在一个节点满足$\ma ...