天天看點

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