mybatis的函数

1) with .. as ( select * from *)

相当于提取一个临时表,以便于复用,在union all中经常用到,以及需要复用的时候用到;
这是CTE的格式,使用此CTE临时表的表达式必须跟在后面,否则就会出错;
可以定义多个CTE临时表,中间用逗号隔开.

2) <if test='sample eq "T".toString()'>

if test 中可以使用java.lang.Sting的方法
<if test='sample.indexOf("t")!=-1'>

3) 常用函数

case when.. then.. else.. end 条件判断
decode('','','') 条件判断
NVL('',0) 空值转换
<where> 条件判断标签
<update> <set> </set> </update> 修改值标签
<chose> <when></when> <otherwise></otherwise> </chose> 选择标签
‘<![CDATA[]]>’ 绝对文本标签,里面的mybatis不解析直接在数据解析,用于标签冲突

4)<resultType>标签相关

<collection>集合标签
<association>关联标签
<discriminator> <case></case> </discriminator> 鉴别器标签,用于根据不同的值来映射不同bo

更多推荐

mybatis的函数