使用tk.mybatis自带批量插入方法insertList出现No setter found for the keyProperty ‘id‘错误

在使用tk.mybatis的insertList方法进行批量插入时遇到错误:'No setter found for the keyProperty 'id' in 'com.xxx.Category'。问题源于数据表主键字段名与实体类属性名不一致。解决方案包括更改数据表主键字段名为'id',或者在CategoryMapper接口中重写insertList方法,将keyProperty设为'categoryId'。
摘要由CSDN通过智能技术生成

使用tk.mybatis自带批量插入方法insertList(List recordList); 时,出现错误:

nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty ‘id’ in ‘com.xxx.Category’.

原因可能是id的问题,查看insertList源码

/**
 * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含`id`属性并且必须为自增列
 *
 * @param recordList
 * @return
 */
@Options(useGeneratedKeys = true, keyProperty = "id")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值