Not able to use Iterable<Map<String, Object>> as return type in GraphRepository SDN 3

341 views
Skip to first unread message

anshul goel

unread,
Jun 4, 2015, 5:43:18 PM6/4/15
to ne...@googlegroups.com

I have the following GraphRepository class for Feed.

public interface FeedRepository extends GraphRepository<Feed>, RelationshipOperationsRepository<Feed>{

    Feed findById(Long id);
    List<Feed> findByFeedType(String feedtype); 
    @Query("match (user:User {username:{0}}), (f:Feed) where f.feedType in {1} "
            + "with user,f "
            + "order by f.timeAdded desc "
            + "optional match (user)-[r:LIKED]->(f) "
            + "return f, count(r)")
    Iterable<Map<String, Object>> getAllFeeds(String username, String[] typeFilter, Pageable pageable);

}

Getting the following error while compiling the code. I am using Spring Data neo4j version 3.

Caused by: java.lang.IllegalStateException: Method has to have one of the following return types! [interface org.springframework.data.domain.Slice, interface org.springframework.data.domain.Page, interface java.util.List] at org.springframework.data.repository.util.ClassUtils.assertReturnTypeAssignable(ClassUtils.java:112) at org.springframework.data.repository.query.QueryMethod.(QueryMethod.java:73) at org.springframework.data.neo4j.repository.query.GraphQueryMethod.(GraphQueryMethod.java:45) at org.springframework.data.neo4j.repository.GraphRepositoryFactory$1.resolveQuery(GraphRepositoryFactory.java:112) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.(RepositoryFactorySupport.java:347) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225) at org.springframework.data.neo4j.repository.GraphRepositoryFactoryBean.afterPropertiesSet(GraphRepositoryFactoryBean.java:70) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)

Michael Hunger

unread,
Jun 4, 2015, 5:48:24 PM6/4/15
to ne...@googlegroups.com
you can only return Page objects from methods with a pageable parameter

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages