title: Spring Data Neo4j 4 : Failed to convert from type java.util.LinkedHashSet<?> to type org.springframework.data.domain.Page<?>
body: <p>Having this Repository method </p>
  
  <pre><code>@Query("MATCH (i:`Interest`) WHERE not(i-[:PARENT]-&gt;()) return i")
  public Page&lt;Interest&gt; findAllByParentIsNull(Pageable pageRequest);
  </code></pre>
  
  <p>It cause (it didn't respect the specification):</p>
  
  <pre><code>org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.util.LinkedHashSet&lt;?&gt; to type org.springframework.data.domain.Page&lt;?&gt; for value '[com.nearofme.model.Interest@12a4479, com.nearofme.model.Interest@15bdfb3, com.nearofme.model.Interest@1af6067, com.nearofme.model.Interest@1c17d4d, com.nearofme.model.Interest@df65f4, com.nearofme.model.Interest@3b140d, com.nearofme.model.Interest@1e24566, com.nearofme.model.Interest@da49c9]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.LinkedHashSet&lt;?&gt; to type org.springframework.data.domain.Page&lt;?&gt;
      at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
      at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192)
      at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176)
      at org.springframework.data.repository.core.support.QueryExecutionResultHandler.postProcessInvocationResult(QueryExecutionResultHandler.java:75)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:439)
  </code></pre>
  
  <p>Debugging the code shows that a conversion is needed at the <code>GraphRepositoryQuery</code> level :</p>
  
  <pre><code>    @Override
      public final Object execute(Object[] parameters) {
          Class&lt;?&gt; returnType = graphQueryMethod.getMethod().getReturnType();
          Class&lt;?&gt; concreteType = graphQueryMethod.resolveConcreteReturnType();
  
          Map&lt;String, Object&gt; params = resolveParams(parameters);
          // could be converted here 
          return execute(returnType, concreteType, getQueryString(), params);
      }
  </code></pre>
  
  <p>The current code convert the result at <code>GraphRepositoryImpl</code> with the private method updatePage that should be used in the <code>GraphRepositoryQuery</code></p>
  
  <pre><code>@Override
      public Page&lt;T&gt; findAll(Pageable pageable, int depth) {
          Collection&lt;T&gt; data = session.loadAll(clazz, convert(pageable.getSort()), new Pagination(pageable.getPageNumber(), pageable.getPageSize()), depth);
          return updatePage(pageable, new ArrayList&lt;T&gt;(data));
      }
  </code></pre>