1. 程式人生 > >報錯信息是Error setting null for parameter #1 with JdbcType OTHER

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

mode term value 類型 需要 ati sca err image

報錯信息是: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>

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

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