MyBatis之Dao接口傳入List類型的參數的處理方式

Mapper.java:

public interface testMapper {
    List<User> getUsers(List<Integer> idList);
}

mapper.xml:

<select id="getUsers" resultType="User">
    select * from
    <where>
        <if test="idList.size()>0 and idList != null ">
            channel_id in
            <foreach item="tempId" collection="idList" open="(" separator="," close=")">
                #{tempId}
            </foreach>
        </if>
    </where>
</select>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章