mybatis 分页参数 RowBounds
来源:互联网 发布:虫虫钢琴软件 编辑:程序博客网 时间:2024/05/22 12:37
分页参数 RowBounds
mybatis不仅支持分页,它还内置一个专门处理分页的类 —— RowBounds源码。
package org.apache.ibatis.session;/** * @author Clinton Begin */public class RowBounds { //设置默认偏移量和默认限制条数。 public static final int NO_ROW_OFFSET = 0; public static final int NO_ROW_LIMIT = Integer.MAX_VALUE; //根据无参构造方法构造默认对象。 public static final RowBounds DEFAULT = new RowBounds(); private int offset; private int limit; public RowBounds() { this.offset = NO_ROW_OFFSET; this.limit = NO_ROW_LIMIT; } public RowBounds(int offset, int limit) { this.offset = offset; this.limit = limit; } public int getOffset() { return offset; } public int getLimit() { return limit; }}
offset属性指的是偏移量,即从第几行开始读取记录。limit是限制条数,也就是每次读取多少条记录。
使用它的方法十分简单,就是在原有的接口上新增这个分页参数。
public List<Role> findRolesByMap(@Param("param1")RoleParam1 param1,@Param("param2")RoleParam2 param2,RowBounds rowBounds);
在我们的映射文件中不需要做任何修改。直接给出测试代码。
sqlSession = SqlSessionFactoryUtils.openSession(); RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class); RoleParam1 param1 = new RoleParam1(); RoleParam2 param2 = new RoleParam2(); param1.setNote("1"); param2.setRoleName("1"); RowBounds rowBounds = new RowBounds(0,2); List<Role> role = roleMapper.findRolesByMap(param1,param2,rowBounds);
阅读全文
0 0
- mybatis 分页参数 RowBounds
- mybatis 分页 RowBounds
- Mybatis逻辑分页原理解析RowBounds
- 博为峰JavaEE技术文章 ——MyBatis RowBounds分页
- MyBatis中的RowBounds
- MyBatis精通之路之分页功能的实现(数组分页、sql分页、拦截器,RowBounds分页)
- mybatis RowBounds 限制查询条数
- Mybatis 分页查询数据(借用map来封装参数)
- MyBatis分页
- MyBatis分页
- mybatis分页
- MyBatis 分页
- Mybatis分页
- MyBatis分页
- MyBatis分页
- MyBatis分页 .
- mybatis分页
- mybatis--分页
- IAR for 430软件的简单使用
- QT之信号槽(一)
- 1006. 换个格式输出整数 (15)
- 百炼 3468:电池的寿命
- zookeeper注册配置与启动
- mybatis 分页参数 RowBounds
- 数据结构实验之链表二:逆序建立链表
- ESL读书笔记2b:bias-variance tradeoff之 knn在k=1情况下受目标函数影响的bias和variance
- 静态方法加synchronized和非动态方法加synchronized的区别
- python的三目
- python之numpy库学习常用函数(矩阵运算)
- 兵法三十六计第一计-瞒天过海。
- GDI位图实现
- java中获取二维数组的行数和列数