<if test="status!= null and status!= ''">
status=#{status},
</if>
在mybatis中這樣寫的話,如果是String類型的話是沒有任何問題的,但是如果是傳入的Integer等數字類型的話就會出現傳入0被判斷為空的現象,但是也不是必現的,為什麼不是必現的也不太清,但是如果變量的值是0,即 status= 0, mybatis在進行 status!= ‘’ 的時候會認為 status的值是空字元串, 即 status== ‘’ 為true。是以如果是數字類型隻需要判斷 != null 即可
導緻更新失敗
<if test="status!= null >
status=#{status},
</if>