一、携带参数
Java的查询参数里携带了一个集合。
复制代码
1
2
3
4
5@Data public class TeacherParam { private List<Long> teacherIds; }
这个参数作为查询Mapper的参数。
复制代码
1
2
3
4
5
6@Repository @Mapper public interface ClassRoomMapper { List<Teacher> queryTeacher(TeacherParam teacherParam); }
以下是调用这个内部集合的例子。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16<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--------查询参数携带集合内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复