mybatis07--动态sql
程序员文章站
2022-04-23 14:10:43
...
sql片段:
<sql id="findUserWhere">
<if test="userCustom!=null">
<if test="userCustom.username!=null and userCustom.username!=''">
and username like '%${userCustom.username}%'
</if>
<if test="userCustom.address!=null and userCustom.address!=''">
and address like '%${userCustom.address}%'
</if>
<foreach collection="ids" open="and id in(" close=")" item="id" separator=",">
#{id}
</foreach>
</if>
</sql>
foreach:在statement通过foreach遍历parameterType中的集合类型。
collection:集合属性的名称
open:循环第一次拼接的串
close:循环结束拼接的串
item:每次循环取到的对象
seaparator:没两次循环中拼接的串