mybatis 參數爲String,if test讀取該參數代碼: java
<select id="getMaxDepartId" parameterType="java.lang.String" resultType="java.lang.String">
SELECT MAX(DEPART_ID) FROM T_P_DEPART
<where>
<if test="_parameter!=null and _parameter!=''">
AND DEPART_PID = #{departId,jdbcType=VARCHAR}
</if>
<if test="_parameter==null or _parameter==''">
AND DEPART_PID IS NULL
</if>
</where>
</select> mybatis