MyBatis学习笔记(八)分页查询
来源:互联网 发布:艺考生软件怎么样 编辑:程序博客网 时间:2024/06/05 15:39
1.逻辑分页
这种方式是将全部数据放到内存中再分页的,与jsp类似
Mapper接口方法:
public List<Student> getAllStudents1(RowBounds rowBounds);映射:
<select id="getAllStudents1" resultMap="studentMap">select * from mybatis_Student</select>和全查询一样,并没有使用rowBounds参数
测试:
@Testpublic void testLogicPaging(){logger.info("测试逻辑分布");StudentMapper mapper = session.getMapper(StudentMapper.class);/** * RowBounds参数:offset:数据偏移 * limit:每页大小 */int pageIndex = 1; //第几页int limit = 2; //每页大小List<Student> list = mapper.getAllStudents1(new RowBounds(limit* (pageIndex-1) ,limit));for(Student stu : list){logger.info(stu.toString());}}
2,物理分页
查询表里的部分数据.
Mapper接口方法:
public List<Student> getAllStudents2(Map<String,Object> map);映射:
<select id="getAllStudents2" resultMap="studentMap">select * from mybatis_Student<if test="start!=null and limit!=null">limit #{start},#{limit}</if></select>
测试:
@Testpublic void testPhysicPaging(){logger.info("测试物理分布");StudentMapper mapper = session.getMapper(StudentMapper.class);/** * RowBounds参数:offset:数据偏移 * limit:每页大小 */int pageIndex = 2; //第几页int limit = 2; //每页大小Map<String,Object> map = new HashMap<String,Object>();map.put("start",limit* (pageIndex-1) );map.put("limit", limit);List<Student> list = mapper.getAllStudents2(map);for(Student stu : list){logger.info(stu.toString());}}}
0 0
- MyBatis学习笔记(八)分页查询
- mybatis学习笔记--分页查询
- MyBatis学习(八)- MyBatis分页实现 - Oracle
- mybatis学习笔记(八)Sqlsession详解
- myBatis学习笔记(10)——使用拦截器实现分页查询
- ThinkPHP学习笔记(八)条件查询
- MySQL学习笔记(八)子查询
- mybatis 学习记录(2)—— 分页查询
- MyBatis学习笔记(五)关联查询
- 关联查询---Mybatis学习笔记(九)
- 查询缓存---Mybatis学习笔记(十)
- 关联查询---Mybatis学习笔记(九)
- 查询缓存---Mybatis学习笔记(十)
- MyBatis ( 三)分页查询
- Mapper.xml映射文件---Mybatis学习笔记(八)
- J2EE系列之MyBatis学习笔记(八)-- 杂项
- Mapper.xml映射文件---Mybatis学习笔记(八)
- JDBC笔记(八)分页
- 清除eclipse中svn历史资源位置
- OLE Drag&Drop 介绍
- 59.两个APP之间的跳转[[UIApplication sharedApplication] openURL:url]与数据传递
- 用户界面之 view 二
- 60.删除SVN版本控制文件 .svn文件删除方法
- MyBatis学习笔记(八)分页查询
- SSDB安装
- 62.在设置autolayout时候 constrain to margins 和 Update Frames 这两项是什么意思?
- 锻炼出最牛程序员的编码 套路
- hdu3591 The trouble of Xiaoqian(多重背包问题)
- Android中dp sp和pt
- Android SQLite数据库学习
- 用户界面之 view 三
- 阻塞非阻塞与同步异步