Sometimes, we may need to work with huge volumes of data, such as with tables with millions of records. Loading all these records may not be possible due to memory constraints, or we may need only a fragment of data. Typically in web applications, pagination is used to display large volumes of data in a page-by-page style.

MyBatis can load table data page by page using RowBounds. The RowBounds object can be constructed using the offset and limit parameters. The parameter offset refers to the starting position and limit refers to the number of records.

Suppose if you want to load and display 25 student records per page, you can use the following query:

<select id="findAllStudents" resultMap="StudentResult">
select * from Students
</select>

Then, you can load the first page (first 25 records) as follows:

int offset =0 , limit =25;
RowBounds rowBounds = new RowBounds(offset, limit);
List<Student> = studentMapper.getStudents(rowBounds);

To display the second page, use offset=25 and limit=25; for the third page, use offset=50 and limit=25.

MyBatis(3.2.3) - Paginated ResultSets using RowBounds的更多相关文章

  1. Table of Contents - MyBatis

    Getting Started with MyBatis Hello World Integration with Spring Bootstrapping MyBatis Configuring M ...

  2. SSM(Spring + Springmvc + Mybatis)框架面试题

    JAVA SSM框架基础面试题https://blog.csdn.net/qq_39031310/article/details/83050192 SSM(Spring + Springmvc + M ...

  3. mybatis查询语句的背后之参数解析

    转载请注明出处... 一.前言 通过前面我们也知道,通过getMapper方式来进行查询,最后会通过mapperMehod类,对接口中传来的参数也会在这个类里面进行一个解析,随后就传到对应位置,与sq ...

  4. Mybatis 面试题

    题目: 什么是Mybatis?  Mybatis27题 Mybaits的优点 Mybatis27题 MyBatis框架的缺点 Mybatis27题 MyBatis框架适用场合Mybatis27题 My ...

  5. MyBatis的缓存玩法

    重要概念 SqlSession:代表和数据库的一次会话,提供了操作数据库的方法. MappedStatement:代表要发往数据执行的命令,可以理解为SQL的抽象表示. Executor:和数据库交互 ...

  6. JavaSSM框架面试

    一.Spring面试题 1.Spring 在ssm中起什么作用? Spring:轻量级框架 作用:Bean工厂,用来管理Bean的生命周期和框架集成. 两大核心: 1.IOC/DI(控制反转/依赖注入 ...

  7. SSM面试题

    一.Spring面试题 1.Spring 在ssm中起什么作用? Spring:轻量级框架 作用:Bean工厂,用来管理Bean的生命周期和框架集成. 两大核心: 1.IOC/DI(控制反转/依赖注入 ...

  8. Java SSM 框架相关基础面试题

    一.Spring 面试题 1. Spring 在 SSM 中起什么作用? Spring 是轻量级框架,作用是作为 Bean 工厂,用来管理 Bean 的声明周期和框架集成. Spring 的两大核心: ...

  9. SSM框架面试题及答案整理

    一.Spring面试题 1.Spring 在ssm中起什么作用? Spring:轻量级框架 作用:Bean工厂,用来管理Bean的生命周期和框架集成. 两大核心:①. IOC/DI(控制反转/依赖注入 ...

随机推荐

  1. ucGUI 12864 从打点起

      ucGUI是纯C写的的,移植需要定义点阵数,颜色数,和画点函数 以下是ucGUI 12864下的移植 基于ST7920控制的12864液晶用于字符显示很方便的,但网友说用它显示图形并不合适,原因就 ...

  2. php error file_get_contents()

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  3. Educational Codeforces Round 1 D. Igor In the Museum bfs 并查集

    D. Igor In the Museum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598 ...

  4. C#传递参数到线程的n个方法

    [转]http://kb.cnblogs.com/a/888688/ 本片文章的议题是有关于传递参数到线程的几种方法. 首先我们要知道什么是线程,什么时候要用到线程,如何去使用线程,如何更好的利用线程 ...

  5. MySQL并发复制系列三:MySQL和MariaDB实现对比

    http://blog.itpub.net/28218939/viewspace-1975856/ 并发复制(Parallel Replication) 系列三:MySQL 5.7 和MariaDB ...

  6. XtraBackup原理4

    MySQL · 答疑解惑 · 物理备份死锁分析 背景 本文对 5.6 主备场景下,在备库做物理备份遇到死锁的case进行分析,希望对大家有所帮助. 这里用的的物理备份工具是 Percona-XtraB ...

  7. pydev+python+Eclipse环境搭建+ 调试快捷键汇总

    http://www.cnblogs.com/Bonker/p/3584707.html 编辑器: Eclipse + pydev插件 1. Eclipse是写JAVA的IDE, 这样就可以通用了,学 ...

  8. VMware 9 安装 OS X 10.8.4 并安装 Xcode 4.6

    转自:http://blog.csdn.net/weizi4332/article/details/9264799 学习Objective-C必须要有运行环境,Xcode是最好的选择.不过Window ...

  9. Ruby on Rails Tutorial 第四章 Rails背后的Ruby 之 其他数据类型(二)

    1.方法 定义如下所示: def string_message(str='') if str.empty? "It's an empty string!" else "T ...

  10. HBase-java api 基本操作

    使用的是完全分布式,详细信息为: 操作的Java 代码(抄的别人的) package org.admln.hbase; import java.util.ArrayList; import java. ...