【mybatis】<![CDATA[]]>使用方法
2018-01-02 16:09
435 查看
目的: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>
注意:<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>
相关文章推荐
- 使用CDATA标签,防止 "<="或者">"与Mybatis的标签冲突
- MyBatis中<collection>的两种使用方法,及效率比较
- 博为峰JavaEE技术文章 ——MyBatis <choose>标签使用方法
- 博为峰JavaEE技术文章 ——MyBatis <where>标签使用方法
- 博为峰JavaEE技术文章 ——MyBatis <where>标签使用方法
- Mybatis中<choose> 的使用方法
- 博为峰JavaEE技术文章 ——MyBatis <choose>标签使用方法
- myBatis 实现用户表增删查改操作<方法1 没有使用接口的>(最终版)
- mybatis <![CDATA[ ]]>的作用、使用、注意事项。
- JSP 使用<%@include%>报Duplicate local variable path 错误 解决方法
- Spring配置文件中使用ref local与ref bean的区别. 在ApplicationResources.properties文件中,使用<ref bean>与<ref local>方法如下
- 使用Enumerable.OfType<T>扩展方法实现非泛型集合的Linq查询
- SoapUI使用注意事项——在<!CDATA>节点之前不要有空格
- javascript <![CDATA[的web标准使用方法
- <s:iterator> 中的status 使用方法
- .Net:再现List<T>:相关方法使用
- 启动器和选择器学习-----(6)Extras <wp7 7.1版本中的使用方法>
- Hibernate中使用<generator>设置主键生成方式最通用、最高效的方法
- [C#/ASP.NET]List<>中Sort()、Find()、FindAll()、Exist()的使用方法
- VS2010使用扩展方法对List<T>进行随机排序