mybatis查询参数Set遍历查询
#sqlmapper <resultMap id="BaseResultMap" type="com.LogEntity" > <result column="ID" property="ID" /> <result column="content_md5" property="contentMd5" /> </resultMap> <select id="queryByIds" resultMap="BaseResultMap"> SELECT * FROM `log` WHERE id IN <foreach item="id" index="index" collection="ids" open="(" separator="," close=")"> #{id,jdbcType=INTEGER} </foreach> </select> #接口 public interface LogMapper { List<LogEntity> queryByIds(@Param("ids") Set<Integer> ids); } #实体类 public class LogEntity { /** * ID */ private Integer ID; private String contentMd5; }