不能在<isNotNull>要素相反,试试这样的方法:
<select id="filterQuery" resultMap="guideline" parameterClass="filter">
SELECT * FROM TABLE_NAME
<dynamic prepend="WHERE">
<isNotNull property="lowerLimit" prepend="and">
distance <![CDATA[>=]]> #lowerLimit#
</isNotNull>
<isNotNull property="upperLimit" prepend="and">
distance <![CDATA[<=]]> #upperLimit
</isNotNull>
<isNotNull property="maxLowerLimit" prepend="and">
max_distance <![CDATA[>=]]> #maxLowerLimit#
</isNotNull>
<isNotNull property="maxUpperLimit" prepend="and">
max_distance <![CDATA[<=]]> #maxUpperLimit#
</isNotNull>
<isNotNull property="state" prepend="and">
region = #state#
</isNotNull>
</dynamic>
</select>
<动态>元素将仅在<isNotNull>元素产生输出。