使用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")