Error setting null for parameter

    xiaoxiao2022-07-02  92

    今天生产出了个问题,异常打印如下:

     

    看了一下代码,同事的代码是这样写的:

    <update id="updateConsignOrderById" parameterType="java.util.Map"> update T_TM_CONSIGNORDER <set> END_OP_TIME = #{endOpTime}, END_DATE = #{endDate}, <if test="stateEnd != null"> STATE_END = #{stateEnd}, </if> <if test="endOpOperator != null"> END_OP_OPERATOR = #{endOpOperator} </if> </set> where ID = #{consignID} </update>

    实现类中:

    coverMap.put("consignID", idsArray[i]); coverMap.put("stateEnd", 0L); coverMap.put("endOpTime", null); coverMap.put("endDate", null); coverMap.put("endOpOperator", "");

    写死的null,Oracle不支持,postgreSQL,MySQL,SQLSERVER都支持JdbcType.NULL类型

    需要添加指定类型:

    #{endOpTime,jdbcType=TIMESTAMP}

    另外:代码不严谨,有魔法值,代码行数超过80行,没有备注,不用对象用map传参,为了图省事不指定类型

    最新回复(0)