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