mybatis bug (二):Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'third_party_id' cannot be null


在利用 mybatis 對數據將進行插入數據的時候,出現了如下錯誤:

1 org.springframework.dao.DataIntegrityViolationException: 
2 ### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'third_party_id' cannot be null
3 ### The error may involve com.miaoshaproject.dao.UserDOMapper.insert-Inline
4 ### The error occurred while setting parameters
5 ### SQL: insert into user_info (id, name, gender,        age, telephone, register_mode,        third_party_id)     values (?, ?, ?,        ?, ?, ?,        ?)
6 ### Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'third_party_id' cannot be null
7 ; Column 'third_party_id' cannot be null; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column 'third_party_id' cannot be null

  最后檢查了代碼,發現是在操作數據庫的部分,最后定位到數據庫字段的設計:在使用 insertSelective 方法的時候,如果數據庫字段設置了非空,但是沒有給默認值,會出現上面的錯誤。

  又是因為細節問題導致的報錯問題,實屬不該。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM