• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
黄洪波写点东西的地方
博客园    首页    新随笔    联系   管理    订阅  订阅
mybatis-plus解决 sqlserver批量插入list报错(转)

原文地址:

mybatis-plus解决 sqlserver批量插入list报错

注:我本地的mybits-plus版本为3.1.0

错误1:

org.apache.ibatis.exceptions.PersistenceException: 
### Error flushing statements.  Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.
### Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.

错误2:

未修改代码前,使用默认方法

saveOrUpdateBatch(list)

每次在报错的情况下仅能插入最多1001行数据。

 

跟着杨老师的代码解决问题,由于mybits-plus升级,有个细节需要变更,

InsertBatch 类中

tableInfo.getAllInsertSqlColumn(false)
tableInfo.getAllInsertSqlProperty(false, null)
变更为:
tableInfo.getAllInsertSqlColumnMaybeIf()
tableInfo.getAllInsertSqlPropertyMaybeIf(null)

 

 


posted on 2020-04-02 14:56  红无酒伤  阅读(7094)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3