天天看点

mybatis动态sql根据java中Integer判断不执行otherwise,解决办法更改后代码 :

解决办法,不使用Integer字段,使用string类型字段;

private Integer type;

mapper文件:

<choose>

                <when test="type == 1">

                    1

                </when>  

                <otherwise>

                </otherwise>

            </choose>

即使 type为1也执行0,不会执行1

更改后代码 :

private String type;

mapper文件:

<choose>

                <when test="type == '1'">

                    1

                </when>  

                <otherwise>

                </otherwise>

            </choose>

然后就一切正常了

sql