mybatis批量插入的方式
批量插入数据经常是把一个集合的数据一次性插入数据库,只需要执行一次sql语句,但是批量插入通常会报框架版本号的错误,本人就遇到 com.alipay.zdal.parser.exceptions.a: ERROR ## get sqlparser result from cache has an error:的错误,
项目使用的是支付宝的zdal分表分库中间键配置,出现了很奇葩的错误时间紧也没找到引起的真正原因
所以就找来了另外一种方法:把list放到map集合里面的方法批量插入

<insert id="insertMore"
parameterType="java.util.Map">
insert into account_si_income_info
(user_card_no,user_id,user_name,mobile,medical_card_no,city_no,template_id,template_version,req_msg_id,pay_cost_month,si_type,pay_cost_base,pay_cost_total,pay_cost_person,pay_cost_unit,
account_person,arrive_flag,extend_params,create_time,update_time,collection_type,notified,service_return_url,pid,target_notify_time)
values
<foreach collection="list" item="item" separator =",">
(#{item.userCardNo,jdbcType=VARCHAR},
#{item.userId,jdbcType=VARCHAR},
#{item.userName,jdbcType=VARCHAR},
#{item.mobile,jdbcType=VARCHAR},
#{item.medicalCardNo,jdbcType=VARCHAR},
#{item.cityNo,jdbcType=VARCHAR},
#{item.templateId,jdbcType=VARCHAR},
#{item.templateVersion,jdbcType=VARCHAR},
#{item.reqMsgId,jdbcType=VARCHAR},
#{item.payCostMonth,jdbcType=VARCHAR},
#{item.siType,jdbcType=VARCHAR},
#{item.payCostBase,jdbcType=DECIMAL},
#{item.payCostTotal,jdbcType=DECIMAL},
#{item.payCostPerson,jdbcType=DECIMAL},
#{item.payCostUnit,jdbcType=DECIMAL},
#{item.accountPerson,jdbcType=DECIMAL},
#{item.arriveFlag,jdbcType=VARCHAR},
#{item.extendParams,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateTime,jdbcType=TIMESTAMP},
#{item.collectionType,jdbcType=VARCHAR},
#{item.notified,jdbcType=VARCHAR},
#{item.serviceReturnUrl,jdbcType=VARCHAR},
#{item.pid,jdbcType=VARCHAR},
#{item.target_notify_time,jdbcType=VARCHAR})
</foreach>
</insert>
mybatis批量插入的方式的更多相关文章
- MyBatis批量插入性能及问题
1.mybatis三种批量插入方式对比 2.Mybatis与JDBC批量插入MySQL数据库性能测试及解决方案 3.Mybatis批量插入引发的血案 4.Oracle批量插入数据SQL语句太长出错
- mybatis批量插入数据到oracle
mybatis 批量插入数据到oracle报 ”java.sql.SQLException: ORA-00933: SQL 命令未正确结束“ 错误解决方法 oracle批量插入使用 insert a ...
- springMVC 接收数组参数,mybatis 接收数组参数,mybatis批量插入/批量删除案例
案例是给一个用户赋予多个权限,多个权限用其对应的主键 id 为参数,组成了 一个id数组,传给springMVC,然后springMVC传给mybatis,然后mybatis批量插入.其实类似的场景还 ...
- Oracle 逐条和批量插入数据方式对比
创建测试表 create table base_users ( userid varchar2(16), username varchar2(32), passwd var ...
- 解决Oracle+Mybatis批量插入报错:SQL 命令未正确结束
Mybatis批量插入需要foreach元素.foreach元素有以下主要属性: (1)item:集合中每一个元素进行迭代时的别名. (2)index:指定一个名字,用于表示在迭代过程中,每次迭代到的 ...
- 160421、MyBatis批量插入数据
在程序中封装了一个List集合对象,然后需要把该集合中的实体插入到数据库中,由于项目使用了Spring+MyBatis的配置,所以打算使用MyBatis批量插入,由于之前没用过批量插入,在网上找了一些 ...
- MyBatis批量插入数据(MySql)
由于项目需要生成多条数据,并保存到数据库当中,在程序中封装了一个List集合对象,然后需要把该集合中的实体插入到数据库中,项目使用了Spring+MyBatis,所以打算使用MyBatis批量插入,应 ...
- mybatis批量插入oracle时报错:unique constraint (table name) violated
mybatis批量插入oracle时报错:unique constraint (table name) violated,是因为插入的集合中有两条相同唯一约束的数据.
- Mybatis 批量插入数据
--mybatis 批量插入数据 --1.Oracle(需要测试下是否支持MySQL) < insert id ="insertBatch" parameterType=&q ...
随机推荐
- P4363 [九省联考2018]一双木棋chess
思路 容易发现只能在轮廓线的拐点处落子,所以棋盘的状态可以用一个n+m长度的二进制数表示 转移就是10变成01 代码 #include <cstdio> #include <algo ...
- [exceltolist] - 一个excel转list的工具
https://github.com/deadzq/cp-utils-excelreader <(感谢知名网友的帮助) https://sargeraswang.com/blog/2018/1 ...
- Docker6之Network containers
how to network your containers. Launch a container on the default network Docker includes support fo ...
- Shell脚本(三)
摘自:菜鸟教程 http://www.runoob.com/linux/linux-shell-echo.html Shell命令 1. echo命令 字符串输出 echo "OK! \c& ...
- pyqt5 窗口无边框和透明
https://blog.csdn.net/FanMLei/article/details/79433229 按钮圆形方法属性border-radius:30px; QScrollArea 无法滚动用 ...
- HDU 5985 Lucky Coins(概率)
http://acm.split.hdu.edu.cn/showproblem.php?pid=5985 题意:有多种类型的硬币,每种类型的硬币都有一定的数量,现在每次抛硬币,除去朝下的硬币,知道最后 ...
- MRO和C3算法
本节主要内容: 1.python多继承 2.python经典类的MRO 3.python新式类的MRO,C3算法 4.super() 一.python多继承 在python中类与类之间可以有继承关系, ...
- hdu 6069 Counting Divisors 筛法
Counting Divisors Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Oth ...
- python中的3目运算(3元表达式)
js中 ret = 1 == 1 ? 'true' : 'false' python中 ret = 'true' if 1==1 else 'false'
- ssh连接服务器
1.命令行操作 第一步输入 :ssh 用户名@服务器外网ip 第二步:输入密码,回车 看到welcome提示信息即为登陆成功 输入:exit 退出 2.客户端操作 windows下载ssh软件,安装 ...