// 创建 Example对象 负责条件查询
Example example = new Example(Chapter.class);
// 按id查询
example.createCriteria().andEqualTo(“id”,id);
// 创建 RowBounds对象 负责分页查询 第一个参数index,第二个参数每页展示条数
RowBounds rowBounds = new RowBounds((page - 1) * rows, rows);
// 集成 按条件查询并分页 将两个对象放到继承Mapper接口的接口中
List chapters = chapterDAO.selectByExampleAndRowBounds(example, rowBounds);
通用Mapper条件查询后并分页
最新推荐文章于 2022-09-26 11:35:48 发布
本文介绍如何使用MyBatis的Example对象进行条件查询,以及如何利用RowBounds对象实现分页查询。通过整合Example和RowBounds,可以实现基于条件的高效分页数据检索。
8221





