批量单个条件时,直接用in查询就行,一样会走索引
批量多个条件时,也可以用in ,mybatis写法示范如下
/**
* 查询用户池信息
* @param list 请求参数
* @return 用户池信息列表
*/
List<UserPool> batchGet(@Param("list") List<UserPoolSaveRequestDto> list);
xml写法
<select id="batchGet" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from user_pool
where deleted = 0
and (user_code, organization_code) in
<foreach collection="list" item="item" open="(" close=")" separator=",">
(#{item.userCode,jdbcType=VARCHAR}, #{item.organizationCode,jdbcType=VARCHAR})
</foreach>
</select>