title: Paging and sorting in Spring Data Neo4j 4
body: <p>is there pagination support for custom queries in SDN4? </p>
  
  <ul>
  <li>If yes, how does it work?</li>
  <li>If no, is there a workarround?</li>
  </ul>
  
  <p>I have the following Spring Data Neo4j 4 repository:</p>
  
  <pre><code>@Repository
  public interface TopicRepository 
    extends GraphRepository&lt;Topic&gt;,IAuthorityLookup {
  
    // other methods omitted
    @Query("MATCH (t:Topic)-[:HAS_OFFICER]-&gt;(u:User) "
      + "WHERE t.id = {0} "
      + "RETURN  u")
    public Page&lt;User&gt; topicOfficers(Long topicId, Pageable pageable);
  }
  </code></pre>
  
  <p>And the corresponding testcase:</p>
  
  <pre><code>@Test
  public void itShouldReturnAllOfficersAsAPage() {
    Pageable pageable = new PageRequest(1,10);
    Page&lt;User&gt; officers = topicRepository.topicOfficers(1L, pageable);
    assertNotNull(officers);
  }
  </code></pre>
  
  <p>When I run the test, I run into the following exception </p>
  
  <pre><code>Failed to convert from type java.util.ArrayList&lt;?&gt; to type   org.springframework.data.domain.Page&lt;?&gt; for value '[org.lecture.model.User@1]'; 
  nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.ArrayList&lt;?&gt; to type org.springframework.data.domain.Page&lt;?&gt;
  </code></pre>
  
  <p>This is my setup:</p>
  
  <pre><code>dependencies {
  //other dependencies omitted
    compile("org.neo4j:neo4j-cypher-dsl:2.0.1")
  
  
    compile "org.neo4j.app:neo4j-server:2.2.2"
  
    compile(group: 'org.springframework.data',
            name: 'spring-data-neo4j',
            version: '4.0.0.BUILD-SNAPSHOT')
  
  
    compile(group: 'org.springframework.data',
            name: 'spring-data-neo4j',
            version: '4.0.0.BUILD-SNAPSHOT',
            classifier: 'tests')
  
    testCompile(group: 'org.neo4j',
            name: 'neo4j-kernel',
            version: '2.2.2',
            classifier: 'tests')
  
    testCompile(group: 'org.neo4j.app',
                name: 'neo4j-server',
                version: '2.2.2',
                classifier: 'tests')
  
    testCompile(group: 'org.neo4j',
                name: 'neo4j-io',
                version: '2.2.2',
                classifier: 'tests')
  } 
  </code></pre>
  
  <p>The Snapshot I use should able to handle pagination, since the following test runs just fine:</p>
  
  <pre><code>@Test
  public void itShouldReturnAllTopicsAsAPage() {
  
    Pageable pageable = new PageRequest(1,10);
    Page&lt;Topic&gt; topics = topicRepository.findAll(pageable);
  
    assertNotNull(topics);
  }
  </code></pre>