<!--父子表批量插入  -->
<insert id="insertBatch" parameterType="com.niwopay.dto.benifit.JFOrderVipDTO">
begin
insert into TB_JF_ORDER
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="orderId != null" >
ORDER_ID,
</if>
<if test="extOrderId != null" >
EXT_ORDER_ID,
</if>
<if test="deviceChannel != null" >
DEVICE_CHANNEL,
</if>
<if test="bizChannel != null" >
BIZ_CHANNEL,
</if>
<if test="orderType != null" >
ORDER_TYPE,
</if>
<if test="userId != null" >
USER_ID,
</if>
<if test="orderDate != null" >
ORDER_DATE,
</if>
<if test="orderAmount != null" >
ORDER_AMOUNT,
</if>
<if test="productAmount != null" >
PRODUCT_AMOUNT,
</if>
<if test="payAmount != null" >
PAY_AMOUNT,
</if>
<if test="fee != null" >
FEE,
</if>
<if test="sales != null" >
SALES,
</if>
<if test="freight != null" >
FREIGHT,
</if>
<if test="deliveryState != null" >
DELIVERY_STATE,
</if>
<if test="orderState != null" >
ORDER_STATE,
</if>
<if test="orderDesc != null" >
ORDER_DESC,
</if>
<if test="remark != null" >
REMARK,
</if>
<if test="createDate != null" >
CREATE_DATE,
</if>
<if test="payDate != null" >
PAY_DATE,
</if>
<if test="finishDate != null" >
FINISH_DATE,
</if>
<if test="returnDate != null" >
RETURN_DATE,
</if>
<if test="closeDate != null" >
CLOSE_DATE,
</if>
<if test="deliveryDate != null" >
DELIVERY_DATE,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="orderId != null" >
#{orderId,jdbcType=VARCHAR},
</if>
<if test="extOrderId != null" >
#{extOrderId,jdbcType=VARCHAR},
</if>
<if test="deviceChannel != null" >
#{deviceChannel,jdbcType=VARCHAR},
</if>
<if test="bizChannel != null" >
#{bizChannel,jdbcType=VARCHAR},
</if>
<if test="orderType != null" >
#{orderType,jdbcType=CHAR},
</if>
<if test="userId != null" >
#{userId,jdbcType=VARCHAR},
</if>
<if test="orderDate != null" >
#{orderDate,jdbcType=CHAR},
</if>
<if test="orderAmount != null" >
#{orderAmount,jdbcType=VARCHAR},
</if>
<if test="productAmount != null" >
#{productAmount,jdbcType=VARCHAR},
</if>
<if test="payAmount != null" >
#{payAmount,jdbcType=VARCHAR},
</if>
<if test="fee != null" >
#{fee,jdbcType=VARCHAR},
</if>
<if test="sales != null" >
#{sales,jdbcType=VARCHAR},
</if>
<if test="freight != null" >
#{freight,jdbcType=VARCHAR},
</if>
<if test="deliveryState != null" >
#{deliveryState,jdbcType=CHAR},
</if>
<if test="orderState != null" >
#{orderState,jdbcType=CHAR},
</if>
<if test="orderDesc != null" >
#{orderDesc,jdbcType=VARCHAR},
</if>
<if test="remark != null" >
#{remark,jdbcType=VARCHAR},
</if>
<if test="createDate != null" >
#{createDate,jdbcType=DATE},
</if>
<if test="payDate != null" >
#{payDate,jdbcType=DATE},
</if>
<if test="finishDate != null" >
#{finishDate,jdbcType=DATE},
</if>
<if test="returnDate != null" >
#{returnDate,jdbcType=DATE},
</if>
<if test="closeDate != null" >
#{closeDate,jdbcType=DATE},
</if>
<if test="deliveryDate != null" >
#{deliveryDate,jdbcType=DATE},
</if>
</trim>; insert into TB_JF_ORDER_VIP
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="orderId != null" >
ORDER_ID,
</if>
<if test="accountName != null" >
ACCOUNT_NAME,
</if>
<if test="cardNo != null" >
CARD_NO,
</if>
<if test="bankName != null" >
BANK_NAME,
</if>
<if test="province != null" >
PROVINCE,
</if>
<if test="city != null" >
CITY,
</if>
<if test="branch != null" >
BRANCH,
</if>
<if test="cpTradingStatus != null" >
CP_TRADING_STATUS,
</if>
<if test="bankCardId != null" >
BANK_CARD_ID,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="orderId != null" >
#{orderId,jdbcType=VARCHAR},
</if>
<if test="accountName != null" >
#{accountName,jdbcType=VARCHAR},
</if>
<if test="cardNo != null" >
#{cardNo,jdbcType=VARCHAR},
</if>
<if test="bankName != null" >
#{bankName,jdbcType=VARCHAR},
</if>
<if test="province != null" >
#{province,jdbcType=VARCHAR},
</if>
<if test="city != null" >
#{city,jdbcType=VARCHAR},
</if>
<if test="branch != null" >
#{branch,jdbcType=VARCHAR},
</if>
<if test="cpTradingStatus != null" >
#{cpTradingStatus,jdbcType=CHAR},
</if>
<if test="bankCardId != null" >
#{bankCardId,jdbcType=CHAR},
</if>
</trim>;
end;
</insert>

1、然后调用public int batchUpdate(final String statementName, final List<?> parameters);传入paramter参数的集合即可。

这种方式使用批量插入父子表。

2、不需要批量插入,但是插入一张主表的同时插入多张字表

  <insert id="insertQuotePlan" parameterType="com.taolue.api.interf.insurance.dto.QuotePlanDTO">
begin
insert into TB_CAR_INSURANCE_QUOTA_PLAN
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="QuotePlanID != null" >
QUOTA_PLAN_ID,
</if>
<if test="userId != null" >
USER_ID,
</if>
<if test="CityID != null" >
CITY_ID,
</if>
<if test="VipCarID != null" >
VIP_CAR_ID,
</if>
<if test="InsureStartDate != null" >
INSURE_START_DATE,
</if>
<if test="BusinessStartDate != null" >
BUSINESS_START_DATE,
</if>
<if test="createTime != null" >
CREATE_TIME,
</if>
<if test="itemKind != null" >
INTEM_KIND,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="QuotePlanID != null" >
#{QuotePlanID,jdbcType=VARCHAR},
</if>
<if test="userId != null" >
#{userId,jdbcType=VARCHAR},
</if>
<if test="CityID != null" >
#{CityID,jdbcType=VARCHAR},
</if>
<if test="VipCarID != null" >
#{VipCarID,jdbcType=VARCHAR},
</if>
<if test="InsureStartDate != null" >
#{InsureStartDate,jdbcType=VARCHAR},
</if>
<if test="BusinessStartDate != null" >
#{BusinessStartDate,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=DATE},
</if>
<if test="itemKind != null" >
#{itemKind,jdbcType=CLOB},
</if>
</trim>;
<if test="quotePriceList != null and quotePriceList.size>0" >
<foreach collection="quotePriceList" item="item" index="index">
insert into TB_CAR_INSURANCE_QUOTA_PRICE (quota_id,quota_plan_id,company_id,company_name,company_code) values (#{item.quotaId},#{QuotePlanID},#{item.companyId},#{item.companyName},#{item.companyCode});
</foreach>
</if>
end;
</insert>

mybatis父子表批量插入的更多相关文章

  1. MyBatis 使用 foreach 批量插入

    MyBatis 使用 foreach 批量插入 参考博文 老司机学习MyBatis之动态SQL使用foreach在MySQL中批量插入 使用MyBatis一次性插入多条数据时候可以使用 <for ...

  2. mybatis oracle mysql 批量插入时的坑爹问题--需谨记

    mybatis oracle mysql 批量插入一.oracle的批量插入方式insert into db(id, zgbh, shbzh) select '1', '2', '3' from du ...

  3. Mybatis与JDBC批量插入MySQL数据库性能测试及解决方案

    转自http://www.cnblogs.com/fnz0/p/5713102.html 不知道自己什么时候才有这种钻研精神- -. 1      背景 系统中需要批量生成单据数据到数据库表,所以采用 ...

  4. mybatis使用序列批量插入数据

    mybatis只提供了单条数据的插入,要批量插入数据我们可以使用循环一条条的插入,但是这样做的效率太低下,每插入一条数据就需要提交一次,如果数据量几百上千甚至更多,插入性能往往不是我们能接受的,如下例 ...

  5. Dapper系列之一:Dapper的入门(多表批量插入)

    Dapper介绍  简介:      不知道博客怎么去写去排版,查了好多相关博客,也根据自己做过项目总结,正好最近搭个微服务框架,顺便把搭建微服务框架所运用的知识都进行博客梳理,为了以后复习,就仔细琢 ...

  6. MyBatis操作Oracle批量插入 ORA-00933: SQL 命令未正确结束

    最近在使用MyBatis操作Oracle数据库的时候,进行批量插入数据,思路是封装一个List集合通过Myabtis 的foreach标签进行循环插入,可是搬照Mysql的批量插入会产生 异常 ### ...

  7. mybatis+oracle的批量插入

    // 批量插入,手动控制事务 SqlSession batchSqlSession = null; try { batchSqlSession = sqlSessionTemplate.getSqlS ...

  8. 关于 MyBatis MyBatis-Spring Jdbc 批量插入的各种比较分析

    因为目前SME项目中编写了一套蜘蛛爬虫程序,所以导致插入数据库的数据量剧增.就项目中使用到的3种DB插入方式进行了一个Demo分析: 具体代码如下: 1: MyBatis 开启Batch方式,最普通的 ...

  9. mybatis支持oracle批量插入

    问题:mysql使用mybatis批量插入时,通过foreach标签,将每条记录按照逗号","连接即可. 但是,oracle不支持. oracle支持如下写法: <inser ...

随机推荐

  1. python 代码片段23

    #coding=utf-8 #python还支持动态的实力属性,即那些没有在类定义里生命的属性, #可以"凭空"创造出来 john.tatto='Mom' #继承 class Em ...

  2. Enum(枚举类型)的基本应用

    一.前言 在我们日常的开发过程中,我们经常定义使用常量:在Effective Java建议用枚举来替换常量的使用,提高我们代码的质量,总结一下枚举定义常量的基本使用 二.枚举类型说明      1.枚 ...

  3. 支持向量机(SVM)

    断断续续看了好多天,赶紧补上坑. 感谢july的 http://blog.csdn.net/v_july_v/article/details/7624837/ 以及CSDN上淘的比较正规的SMO C+ ...

  4. [Codeforces] Round #320 (Div.2)

    1.前言 虽然这次我依旧没有参加正式比赛,但是事后还是看了看题目的...一般不怎么刷Codeforces. A.Raising Bacteria You are a lover of bacteria ...

  5. 【CodeVS】1204 寻找字串位置

    题目描述 Description 给出字符串a和字符串b,保证b是a的一个子串,请你输出b在a中第一次出现的位置. 输入描述 Input Description 仅一行包含两个字符串a和b 输出描述  ...

  6. JAVA操作MongoDB数据库

    1. 首先,下载MongoDB对Java支持的驱动包 驱动包下载地址:https://github.com/mongodb/mongo-java-driver/downloads 2.Java操作Mo ...

  7. petapoco定制,比较SQL事务,存储过程,分布式事务(MSDTC)的区别和场景

    使用分布式事务时 就锁死了,而且是只锁编辑的行 使用.netSQL事务一定要执行了一个CUD的SQL才会锁死,而且也是锁行,但是也锁读的行 .netSQL事务要在这里才锁死 结论,对于产品要求细粒度的 ...

  8. 关于 微软必应词典客户端(pc) 的案例分析

    第一部分 调研,评测 ●评测 bug one 在词典界面中搜完单词后,将鼠标移到英文例句上的单词时,会显示对应的中文翻译,而当移到短语时则不对应中文翻译. bug two 用orc强力取词,查询如上图 ...

  9. - dequeueReusableCellWithIdentifier:

    与之对应的还有一个方法: - dequeueReusableCellWithIdentifier:forIndexPath: 1 > - dequeueReusableCellWithIdent ...

  10. jquery中对动态生成的标签响应click事件(二)…与ajax交互使用

    <%@ page language="java" contentType="text/html; charset=GB18030" pageEncodin ...