sqlServer使用MybatisPlus后重写saveBatch找不到对应字段

Momo__zz 2020-06-30 05:26:25
使用myBatisPlus之后要重写saveBatch,因为sqlServer在批量插入的时候官方驱动只返回1个id.

重写saveBatch的相关资料:https://www.jianshu.com/p/49a613811a14

重写后上传批量插入报错,错误如下。




定位后的错误位置如下:
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveBatch(Collection<T> entityList, int batchSize) {
int i = 0;
String sqlStatement = SqlHelper.table(currentModelClass()).getSqlStatement(NoahSqlMethod.INSERT_BATCH.getMethod());
try (SqlSession batchSqlSession = sqlSessionBatch()) {
for (T anEntityList : entityList) {
batchSqlSession.insert(sqlStatement, anEntityList);
if (i >= 1 && i % batchSize == 0) {
batchSqlSession.flushStatements();
}
i++;
}
batchSqlSession.flushStatements();
}
return true;
}

确定过自己的mapper文件已经被打包进入target中。
希望厉害的大佬帮忙看一下。

---------------------------------------------------------
在insert中我的stateMent是com.yms.dao.master.BomRelPnDao.insertBatch,但是我的dao层没有。我的dao层的确不需要。
我感觉应该是托管给数据库的。
...全文
5511 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
尚小纠 2020-11-06
  • 打赏
  • 举报
回复
楼主解决了吗,我也出现了同样的问题
奋斗牛 2020-09-28
  • 打赏
  • 举报
回复

这里需要给上,然后注入进来

2,209

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧