Oracle使用mybatis分页插件-PageHandler

1. 依赖jar包(https://blog.csdn.net/qq_16517483/article/details/72803043)

使用 PageHelper 你只需要在 classpath 中包含 pagehelper-x.x.x.jar  jsqlparser-0.9.5.jar

2.mybatis-config.xml(https://blog.csdn.net/s592652578/article/details/78179998?locationNum=4&fps=1)

4.0.0版本之前:

  1. <plugins>  
  2.         <--
  3.         <plugin interceptor="com.github.pagehelper.PageHelper">  
  4.             <!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->         
  5.             <property name="dialect" value="Oracle"/>  
  6.         </plugin>  
  7.     </plugins> 
4.0.0版本之之后:

  1. <plugins>  
  2.         <plugin interceptor="com.github.pagehelper.PageInterceptor">  
  3.             <!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库, 4.0.0以后版本支持自动识别数据库-->       
  4.             <!-- <property name="dialect" value="Oracle"/>-->     
  5.         </plugin>  
  6.     </plugins> 

3.PageHandler


public void testPageHelper() {
    //这句一定要写在sql执行之前,只对紧跟的第一条语句起作用
    PageHelper.startPage(1, 5,"id desc");
    List<Dept> deptList = session.selectList("DEPT.getAllDept");
    PageInfo<Dept> page = new PageInfo<>(deptList);
    System.out.println("总页数:" + page.getPages());
    System.out.println("页码:" + page.getPageNum());
    System.out.println("总条数:"+page.getTotal());
    System.out.println(deptList.size());
    for (Dept dept : deptList) {
        System.out.println(dept.getName());
    }
}

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值