mybatis在执行sql时候,Integer类型的数据判断为0时候,会默认为空字符串
·
<select id="getCount" resultType="int" parameterType="VmBigDataScreen">
select count(1) from vm_big_data_screen
<where>
<if test="screenname != null and screenname != ''">
and screenName like CONCAT('%',#{screenname},'%')
</if>
<if test="status != null and status != '' ">
and status = #{status,jdbcType=INTEGER}
</if>
</where>
</select>
<if test="status != null ">
and status = #{status,jdbcType=INTEGER}
</if>
当参数是Integer类型的时候,默认为空字符串。status != ' '
所以不要status != ' '写这个条件
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)