MyBatis批量插入主键回写

在使用MyBatis 3.2.4版本进行批量插入到MySQL数据库时遇到异常。问题在于MyBatis在该版本不支持批量插入时主键的自动回写。解决方法是从3.3.1版本开始,MyBatis增加了对批量插入主键回写的支持。要利用此功能,批量插入接口的参数名应为'collection', 'list' 或 'array',且接口参数不应使用@Param注解,并确保接口只有一个参数。" 133895579,5749947,华为OD面试题:求最小步数的C语言解决方案,"['华为面试题', '算法题', 'C编程', '步进计算']
摘要由CSDN通过智能技术生成

使用Mybatis操作批量插入时有如下异常.

  • Mybatis版本: 3.2.4
  • DB: MySQL
ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list]

异常详情:

[2017-02-16 17:20:00]ERROR com.alibaba.dubbo.rpc.filter.ExceptionFilter(line/:87) - [DUBBO] Got unchecked and undeclared exception which called by null. service: com.paas.user.service.modular.IModularService, method: batchInsertModulars, exception: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list], dubbo version: 2.5.3, current host: 127.0.0.1
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [list]
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
    at com.sun.proxy.$Proxy9.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:46)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值