Hibernate JPA

来源:互联网 发布:河北政法网络教学平台 编辑:程序博客网 时间:2024/05/18 03:06

1、spring boot 自带分页工具类  org.springframework.data.domain.Pageable


/**  * 假如page=1,size=5,则 limit 6,5 ,因为page代表索引页,从第0页开始,后面两个是排序的参数  */public PageRequest(int page, int size, Direction direction, String... properties) {      ......    }
使用方法:
  //@Service中,sellerFoodDao是继承 JpaRepository<SellerFoodE,Long>的接口,即可使用JPA查询到
 Pageable pageable = new PageRequest(page - 1, Constant.PAGE_SIZE, Sort.Direction.ASC, "foodName");sellerFoodDao.findByRestaurantAndFoodNameLike(rest, "%" + likeStr + "%", pageable);



原创粉丝点击