<selectresultType="User"id="getUserList_choose">
select * from smbms_user where 1=1
<choose><whentest="userName != null and userName != ''">and userName like CONCAT ('%',#{userName},'%') </when><whentest="userCode != null and userCode != ''">and userCode like CONCAT ('%',#{userCode},'%') </when><whentest="userRole != null">and userRole=#{userRole} </when><otherwise><!-- and YEAR(creationDate) = YEAR(NOW()) -->
and YEAR(creationDate) = YEAR(#{creationDate})
</otherwise></choose></select>
foreach
<selectid="getUserByConditionMap_foreach_map"resultMap="userMapByRole">
select * from smbms_user where gender = #{gender} and userRole in
<foreachclose=")"separator=","open="("item="roleMap"collection="roleIds">#{roleMap} </foreach></select><selectid="getUserByRoleId_foreach_array"resultMap="userMapByRole">
select * from smbms_user where userRole in
<foreachclose=")"separator=","open="("item="roleIds"collection="array">#{roleIds} </foreach></select><selectid="getUserByRoleId_foreach_list"resultMap="userMapByRole">
select * from smbms_user where userRole in
<foreachclose=")"separator=","open="("item="roleList"collection="list">#{roleList} </foreach></select>