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)

 

 


					


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM