mapper.xml 关键词
?xml [version="1.0" encoding="utf-8"] !DOCTYPE[mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"] mapper [namespace]>+ resultMap[id type]>+ id[column jdbcType property]+ result[column jdbcType property]+ resultMap[id type extends]>+ id[column jdbcType property]+ result[column jdbcType property]+ sql[id] delete[id="" parameterType=""] update[id="" parameterType=""]set> if[test] insert[id="" parameterType=""]> trim[prefix="(" suffix=")" suffixOverrides=","]> if[test] select[id parameterType resultType]> include [refid]+ if[test]>+ bind[name value] choose-when[test]+ foreach[collection item index open separator close]
动态sql-if
<if test="title != null">
AND title like #{title}
</if>
<if test="author != null and author.name != null">
AND author_name like #{author.name}
</if>
动态sql-choose-when-otherwise
<choose>
<when test="title != null">
AND title like #{title}
</when>
<when test="author != null and author.name != null">
AND author_name like #{author.name}
</when>
<otherwise>
AND featured = 1
</otherwise>
</choose>
动态sql-foreach
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
动态sql-bind
<bind name="pattern" value="'%' + _parameter.getTitle() + '%'" />
SELECT * FROM BLOG WHERE title LIKE #{pattern}