目的:XML中不希望转义的SQL可以写入<![CDATA[ ]]括号里面,比如where中常用的>、<=、& 等字符。因为写在[ ]里面的内容会被解析器忽略。
注意:<if>、<where> 等标签不要写里面,因为这些标签页不会被解析。尽量简化<![CDATA[ ]]> 中的代码。
<select id="selectByTS" resultMap="BaseResultMap" parameterType="com.tianrui.dc.dao.nc.bean.BdCustorg">
select
<include refid="Base_Column_List" />
from BD_STORDOC tti
<where>
<if test="enablestate !=null and enablestate !=''">
enablestate =#{enablestate,jdbcType=DECIMAL}
</if>
<if test='maxTs != null and maxTs!="" '>
<![CDATA[and to_date(tti.ts,'yyyy/mm/dd hh24:mi:ss') >to_date(#{maxTs},'yyyy/mm/dd hh24:mi:ss')]]>
</if>
</where>
</select>