报错信息是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>

解决办法是:检查前端部分传过来的数据是否正确

猜你喜欢

转载自www.cnblogs.com/zzxzxn/p/10761645.html