Dao层接口:
List<EntryResource> findByRidAndType(List<EntryResource> entryResources);
XML语句:
<select id="findByRidAndType" resultMap="entryResource" parameterType="list">
SELECT
*
FROM
t_entry_resource a
WHERE
<foreach collection="list" index="index" item="entryResources" open="(" close=")" separator="or">
( `type`=#{entryResources.type} and resource_id=#{entryResources.resourceId} )
</foreach>
</select>
(1) select count(*) from users id in (x1,x2,x3,...)
<select id="countByUserList" resultType="int" parameterType="list">
select count(*) from users
<where>
id in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item.id, jdbcType=NUMERIC}
</foreach>
</where>
</select>