我是靠谱客的博主 迷你玫瑰,这篇文章主要介绍MyBatis--------查询参数携带集合,现在分享给大家,希望可以做个参考。

一、携带参数

       Java的查询参数里携带了一个集合。

@Data
public class TeacherParam {

    private List<Long> teacherIds;
}

        这个参数作为查询Mapper的参数。

@Repository
@Mapper
public interface ClassRoomMapper {

    List<Teacher> queryTeacher(TeacherParam teacherParam);
}

        以下是调用这个内部集合的例子。

    <select id="queryTeacher" resultType="com.tyzhou.stu.model.Teacher">
        select
            id id,
            name name
        from
            m_teacher
        where
        1=1
        <if test="teacherIds != null and teacherIds.size()>0">
            and id in
            <foreach item="tId" index="index" 
                                 collection="teacherIds" open="(" close=")" separator=",">
                #{tId}
            </foreach>
        </if>
    </select>

更多MyBatis使用经验

         MyBaits操作经验目录贴

最后

以上就是迷你玫瑰最近收集整理的关于MyBatis--------查询参数携带集合的全部内容,更多相关MyBatis--------查询参数携带集合内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部