mybatis sqlmapper test 判断非字符串类型的值
发布日期:2022-03-03 10:44:13 浏览次数:8 分类:技术文章

本文共 953 字,大约阅读时间需要 3 分钟。

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>

转载地址:https://blog.csdn.net/yangjiegang8/article/details/77855171 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:selenium以及selenium driver对应各主流浏览器版本小结(计划持续更新)
下一篇:pywin32实践 判断程序窗口是否失去响应

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月26日 02时45分25秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章