問題
在用mybatis-plus更新數據的時候,更新失敗,錯誤信息如下:
Cause: org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='et.verificationCode', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #5 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 無效的列類型: 1111
細看錯誤信息可以看到是用於我要更新的值中有null值導致的,mybatis找不到對應的jdbcType。。。
解決辦法
一種是給對應的字段顯示的配置上jdbcType,當然這種比較麻煩,所以推薦全局配置
mybatis-plus.configuration.jdbc-type-for-null=varchar
參考文章
https://www.cnblogs.com/pangguoming/p/9041140.html
https://www.cnblogs.com/arebirth/archive/2019/08/30/11436432.html