報錯信息是Error setting null for parameter #1 with JdbcType OTHER


報錯信息是:nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='__frch_item_0.userId', mode=IN, javaType=class java.lang.Long, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 無效的列類型: 1111

報錯原因是:傳過來的參數類型不對,需要的是一個long型的數據,結果傳過來是一個String類型的數據,導致接收不了,網上說在傳過來的數據jdbcType=NUMERIC,如下,數據庫里number類型的數據寫成NUMERIC,發現換了一個錯,但是仍然沒有解決

<insert id="batchUserRole" useGeneratedKeys="false">
insert all
<foreach item="item" index="index" collection="list">
into sys_user_role(user_id, role_id) values (#{item.userId,jdbcType=NUMERIC},#{item.roleId,jdbcType=NUMERIC}
</foreach>
SELECT 1 FROM DUAL
</insert>

解決辦法是:檢查前端部分傳過來的數據是否正確

 


免責聲明!

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



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