<select id="getProcess" resultType="com.example.flowdemo.pojo.PcProcess">
select * from pc_process
<where>
<if test="proceeId != null">
id =#{proceeId}
</if>
<if test="processType != null">
and process_type =#{processType}
</if>
</where>
</select>
foreach+in
<select id="selectInList" resultMap="sysUserMap">
select <include refid="sysUserSql"/>
from sys_user where id in
<foreach collection="idList" open="(" close=")" separator="," item="id" index="i">
#{id}
</foreach>
</select>
foreach+insert
<insert id="saveUsers">
insert into user (id, username, password)
values
<foreach collection="list" item="user" separator=",">
(#{user.id}, #{user.username}, #{user.password})
</foreach>
</insert>
if-else = choose-when
<select id="findActiveBlogLike" resultType="Blog">
SELECT * FROM BLOG WHERE state = ‘ACTIVE’
<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>
</select>