关于mybatis使用map传参0和 " !='' " 的问题

记录一下我在开发中遇到的一个小问题:

  dao中有一个接口的传入类型为map:public abstract List<ActivityEntryDo> selectByDemocConditionAsc(Map<String, Object> paramMap);

  我在service调用该接口时,有一个参数为int类型且值为0,对应的sql中有一个判断:

  <if test="checkStatus != null and checkStatus != '' ">
                AND t.check_status in
                <foreach collection="checkStatus" index="index" item="item"
                            open="(" separator="," close=")">
                            #{item}
                        </foreach>
         </if>

  以为会将0作为条件查询,然后log打印出的sql中并没有该参数,诧异!!!!!!

  解决方案:将参数作为string传入即可解决。

       参考文章:https://blog.csdn.net/bei_fang_du_lang/article/details/79093217,如有侵权,请联系我删除!

  注:首次写博,不喜勿喷。

  

猜你喜欢

转载自www.cnblogs.com/wangys-web/p/9618205.html