mybatis的一个bug,将整数0识别为null,导致sql执行失败

本文内容整理来源:http://blog.csdn.net/john1337/article/details/70230563


今天在使用mybatis时遇到一个问题,Java代码中传递的整数0在mybatis中被识别成null

[html]  view plain  copy
  1. <where>  
  2.     <if test="status != null and status !=''">  
  3.         and status=#{status,jdbcType=INTEGER}  
  4.     </if>  
  5. </where>  


如果java代码需要往mybatis传递整数0,那么需要使用增强版的判断,具体如下所示:

[html]  view plain  copy
  1. <where>  
  2.     <if test="status != null and status !='' or status==0">  
  3.         and status=#{status,jdbcType=INTEGER}  
  4.     </if>  
  5. </where>  

猜你喜欢

转载自blog.csdn.net/qq_33661044/article/details/83894008
今日推荐