zoukankan      html  css  js  c++  java
  • 关于SpringbootJPA分页 PageRequest过时的办法

    看了网上很多博客,都是在用 new PageRequest的方法创建Pageable对象。可是估计很多同学写了之后才发现原来这个方法作者已经标记为过时了;

    替代的方法是不要new PageRequest,而是直接用 PageRequest.of这个方法 根据你的需求选择入参;

    下面贴出对比

    @Override
    @Transactional(readOnly = true) // 只读事务
    public Page<People> getPage(Integer pageNum, Integer pageLimit) {
    Pageable pageable =new PageRequest(pageNum - 1,pageLimit);
    return emr.findAll(pageable);
    }

    
    
    @Override
    @Transactional(readOnly = true) // 只读事务
    public Page<People> getPage(Integer pageNum, Integer pageLimit) {
        Pageable pageable =PageRequest.of(pageNum - 1,pageLimit);
        return emr.findAll(pageable);

    }
  • 相关阅读:
    day04用户交互和运算符
    day04垃圾回收机制
    day4
    B2. K for the Price of One (Hard Version)
    C. New Year and Permutation
    Rational Ratio
    C. Two Arrays
    D. MEX maximizing
    B. Infinite Prefixes
    C. Obtain The String
  • 原文地址:https://www.cnblogs.com/igong/p/9817037.html
Copyright © 2011-2022 走看看