mybatis, a type byte for comparison
mybatis, a type byte for comparison. Only need to test! = Null on the line.
In mybatis in for if some conditions are, we often use the "test! = Null && teat! = ''", But for byte class, the only test! = Null on the line.
Not just beginning to be known, then spent half a day in the pit. . So here, we intend to conduct some understanding of the pit, in order to avoid later into the pit.
mybatis if the condition determination, which is a digital type numberType (int, long, double, float, Integer ...) like one (if its non-null character is determined, and this time the digital type is 0, then Here is the first one if not enter execution.
<where>
<if test="numberType!= null and numberType!=''">
AND NUMBER_TYPE = #{numberType}
</if>
<if test=" businessEndTime != '' and businessEndTime != null">
<![CDATA[AND BUSINESS_TIME <= TO_DATE(#{businessEndTime},'yyyy-mm-dd hh24:MI:SS')]]>
</if>
</where>
Digital type of non-null character judgment itself unreasonable, produced this irrational situation is understandable. 0 is as false, so it will not enter the conditions, and the type of business involved judgment not on the sql in java in judgment, or poor maintenance.
reference:
https://blog.csdn.net/lich1n/article/details/73511180