<!-- 批量添加派车单子表数据 -->
<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常用批量方法的更多相关文章

  1. Mybatis 实现批量插入和批量删除源码实例

    Mybatis 实现批量插入数据和批量删除数据 学习内容: 准备工作 1.数据库新建表 2.新建 Maven 项目和设置编译版本及添加依赖 3.新建 db.properties 4.新建 mybati ...

  2. mybatis执行批量更新update

    Mybatis的批量插入这里有http://ljhzzyx.blog.163.com/blog/static/38380312201353536375/.目前想批量更新,如果update的值是相同的话 ...

  3. 161102、MyBatis中批量插入

    方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...

  4. Elasticsearch java api 常用查询方法QueryBuilder构造举例

    转载:http://m.blog.csdn.net/u012546526/article/details/74184769 Elasticsearch java api 常用查询方法QueryBuil ...

  5. Mybatis+mysql批量插入性能分析测试

    前言 今天在网上看到一篇文章(后文中的文章指的就是它) https://www.jianshu.com/p/cce617be9f9e 发现了一种有关于mybatis批量插入的新方法,而且看了文章发现我 ...

  6. Mybatis 常用注解

    Mybatis常用注解对应的目标和标签如表所示: 注解 目标 对应的XML标签 @CacheNamespace 类 <cache> @CacheNamespaceRef 类 <cac ...

  7. ETL流程介绍及常用实现方法

    ETL是英文Extract-Transform-Load 的缩写,用来描述将数据从来源端经过抽取(extract).转换(transform).加载(load)至目的端的过程.常见于数据仓库开发中将数 ...

  8. mysql基础---->mybatis的批量插入(一)

    这里面记录一下使用mybatis处理mysql的批量插入的问题,测试有可能不准.只愿世间风景千般万般熙攘过后,字里行间,人我两忘,相对无言. mybatis的批量插入 我们的测试主体类是springb ...

  9. 170829、mybatis使用oracle和mybatis中批量更新

    一.mybatis执行批量更新batch update 的方法(mysql数据库) 1.数据库连接必须配置:&allowMultiQueries=true(切记一定要加上这个属性,否则会有问题 ...

随机推荐

  1. centos redhat 安装g++

    正确安装命令 : yum install gcc-c++ libstdc++-devel 安装后可以在/bin/找到

  2. 【解决方案】Pyinstaller打包exe策略(简单实用)

    场景说明 在业务场景中, 经常需要Python开发一些小程序/脚本/GUI界面,进行简单的项目测试或未安装Python 的小伙伴们使用. 使用Pyinstaller将Python脚本或者项目打包,生成 ...

  3. mysql登录遇到ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    执行mysql  -uroot  -p,出现如下问题 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pass ...

  4. 动态sql & 抽取可重用sql

    抽取可重用的sql片段 抽取:<sql id="xx"></sql> 使用:<include refid="xx">< ...

  5. 运行级别和找回root密码

    运行级别说明 0 :关机 1 :单用户 [类似安全模式,这个模式可以帮助找回root密码 2:多用户状态没有网络服务 3:多用户状态有网络服务 [使用] 4:系统未使用保留给用户 5:图形界面 6:系 ...

  6. MySQL统计总数就用count(*),别花里胡哨的《死磕MySQL系列 十》

    有一个问题是这样的统计数据总数用count(*).count(主键ID).count(字段).count(1)那个效率高. 先说结论,不用那么花里胡哨遇到统计总数全部使用count(*). 但是有很多 ...

  7. vue自定义指令实例使用(实例说明自定义指令的作用)

    在写vue项目的时候,我们经常需要对后台返回的数据进行大量的渲染操作,其中就包含了大量的对特殊数据的进一步处理,比如说时间戳.图片地址.特殊数据显示等等特殊数据处理改进. 其实遇到这种情况,通过Vue ...

  8. 大爽Python入门教程 3-2 条件判断: if...elif..else

    大爽Python入门公开课教案 点击查看教程总目录 简单回顾if 回顾下第一章的代码 >>> x = 5 >>> if x > 0: ... print(&q ...

  9. 单元测试NUnit,mock组件NSubstitute,信号量SemaphoreSlim,异步lock等例子

    public class LockTest { private IDatabase _database; private readonly Random _random = new Random(); ...

  10. Atcoder Regular Contest 072 C - Alice in linear land(思维题)

    Atcoder 题面传送门 & 洛谷题面传送门 首先求出 \(s_i\) 表示经过 \(i\) 次操作后机器人会位于什么位置,显然 \(s_0=D\),\(s_i=\min(s_{i-1},| ...