zl程序教程

您现在的位置是:首页 >  其他

当前栏目

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

2023-03-14 10:15:28 时间

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));

    }

......