Skip to content

Built-in Pagination and Sorting support #13

@kornelrabczak

Description

@kornelrabczak

Problem

The library lacks native support for Spring Data's pagination and sorting abstractions. Users must manually implement pagination using SKIP and LIMIT in Cypher queries, resulting in verbose and error-prone code.

Current Workaround

public interface PersonRepository extends NodeRepository<Person, String, Void, Person> {
    @Query("MATCH (n:Person) RETURN n ORDER BY n.name SKIP $offset LIMIT $limit")
    List<Person> findAllPaginated(@Param("offset") int offset, @Param("limit") int limit);
    @Query("MATCH (n:Person) RETURN count(n)")
    long countAll();
    // Manual pagination logic in service layer
    Page<Person> findAll(Pageable pageable) {
        int offset = pageable.getPageNumber() * pageable.getPageSize();
        List<Person> content = findAllPaginated(offset, pageable.getPageSize());
        long total = countAll();
        return new PageImpl<>(content, pageable, total);
    }
}

Expected Behavior (Spring Data Style)

public interface PersonRepository extends NodeRepository<Person, String, Void, Person> {
    Page<Person> findAll(Pageable pageable);
    Page<Person> findByAgeGreaterThan(int age, Pageable pageable);
    Slice<Person> findByActiveTrue(Pageable pageable);
    List<Person> findByCity(String city, Sort sort);
    List<Person> findAll(Sort sort);
}

Proposed Solution

Implement Spring Data's Pageable, Page, Slice, and Sort abstractions with automatic Cypher generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions