自学内容网 自学内容网

mapper.xml中的强制类型转换

联系

https://blog.csdn.net/qq_40603125/article/details/141632754?spm=1001.2014.3001.5501

  • 之前转日期的遇到过这个问题

问题

mapper.xml文件会将字段转换为要比较的类型,这里是隐式转换,不易发觉

<if test="status != null and  and status  != ''"> status = #{status},</if>

status 是1的时候,正常更新,但是status 是0的时候就不行

  • 0会被强制转换成字符串和 ''比较,0转换为字符串就是‘’,所以就不满足条件,不会更新

原文地址:https://blog.csdn.net/qq_40603125/article/details/142492301

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!