BUG概要
长话短说。在TbMonitorSystemInfo类里有2个Short类型的属性 isUsing 和 failSendMassage 。在Mybatis的mapper.xml的截取出的一个update片断中(如下sql),每次执行这test判断的结果都是false以致于生成的sql不完整。
<update id="updatePartByPK" parameterType="com.略.entity.TbMonitorSystemInfo">
update TB_MONITOR_SYSTEM_INFO
<set>
<if test = "isUsing != null and isUsing !=''"> IS_USING = #{isUsing,jdbcType=DECIMAL}, </if>
<if test = "failSendMassage != null and isUsing !=''"> FAIL_SEND_MASSAGE = #{failSendMassage,jdbcType=DECIMAL}, </if>
</set>
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
</update>
解决方案
如下sql,去掉 test = ” xxx !=” ” 或者 改xxx属性为String类型。
<update id="updatePartByPK" parameterType="com.略.entity.TbMonitorSystemInfo">
update TB_MONITOR_SYSTEM_INFO
<set>
<if test = "isUsing != null and isUsing !=''"> IS_USING = #{isUsing,jdbcType=VARCHAR}, </if>
<if test = "failSendMassage != null"> FAIL_SEND_MASSAGE = #{failSendMassage,jdbcType=DECIMAL}, </if>
</set>
where SEQ_NO = #{seqNo,jdbcType=VARCHAR}
</update>