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(切记一定要加上这个属性,否则会有问题 ...
随机推荐
- python连接集群mongodb,封装增删改查
1.下载pymongo pip install pymongo 2.直接上代码 [ini配置文件] 封装读ini省略~~ [db.py] class Database(): def __init__( ...
- sqlalchemy create single table
User.__table__.drop(engine) User.__table__.create(engine) https://stackoverflow.com/a/45287771/80250 ...
- 001.AD域控简介及使用
一 AD概述 1.1 AD简介 域(Domain)是Windows网络中独立运行的单位,域之间相互访问则需要建立信任关系. 当一个域与其他域建立了信任关系后,2个域之间不但可以按需要相互进行管理,还可 ...
- 菜鸡的Java笔记 - java 线程的同步与死锁 (同步 synchronization,死锁 deadlock)
线程的同步与死锁 (同步 synchronization,死锁 deadlock) 多线程的操作方法 1.线程同步的产生与解决 2.死锁的问题 ...
- cesium开发(1)搭建 vue + cesium开发环境
进入新公司一段时间了,新公司业务主要从事卫星方面等webgl的开发,主要使用了leafletjs和cesium,其中cesium难度较大,需求较多,再进行了一段时间的使用开发后依旧感到有些力不从心, ...
- [年薪60W分水岭]基于Netty手写Apache Dubbo(带注册中心和注解)
阅读这篇文章之前,建议先阅读和这篇文章关联的内容. 1. 详细剖析分布式微服务架构下网络通信的底层实现原理(图解) 2. (年薪60W的技巧)工作了5年,你真的理解Netty以及为什么要用吗?(深度干 ...
- [bzoj1106]立方体大作战
先贪心,容易发现如果两个点中间没有点对,那么一定可以先把这两个点消掉分析一下,就可以发现这样两个点的答案就是这两个点对中间不成对的点数量扫描过去,线段树维护每一个点的权值(是否会被算入答案)即可 1 ...
- elasticsearch学习(1)
下载解压,elasticsearch.bat启动 elasticsearch目录: bin 启动文件config 配置文件 log4j2 日志配置文件 jvm.options java虚拟机相关的配置 ...
- ElasticJob分布式任务调度应用v2.5.2
为何要使用分布式任务调度 **本人博客网站 **IT小神 www.itxiaoshen.com 演示项目源码地址** https://gitee.com/yongzhebuju/spring-task ...
- Golang进阶,揉碎数据库中间件,干货满满!
目录 必读 一.Centos7.Mac安装MySQL 二.主从复制原理 2.1.基于binlog_filename + position 2.2.基于GTID 三.my.cnf 四.测试SQL 五.中 ...