深入实践Spring Boot3.1.3 分页查询设计

    xiaoxiao2024-03-31  119

    3.1.3 分页查询设计

    对于新型的Neo4j数据库来说,由于它的资源库遵循了JPA的规范标准来设计,在分页查询方面有的地方还不是很完善,所以在分页查询中,设计了一个服务类来处理,如代码清单3-3所示。其中,使用Class<T>传入调用的实体对象,使用Pageable传入页数设定和排序字段设定的参数,使用Filters传入查询的一些节点属性设定的参数。

    代码清单3-3 Neo4j分页查询服务类

    @Service

    public class PagesService<T> {

        @Autowired

        private Session session;

     

        public Page<T> findAll(Class<T> clazz, Pageable pageable, Filters filters){

            Collection data = this.session.loadAll(clazz, filters, convert

    (pageable.getSort()), new Pagination(pageable.getPageNumber(), pageable.getPageSize()), 1);

            return updatePage(pageable, new ArrayList(data));

        }

    ......

    最新回复(0)