cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Records with more than one value cannot be converted without a mapper

I want to aggregate data in my SpringBoot project like below↓

public interface PeopleRepository extends Neo4jRepository<People,Long> {
    @Query("match (n:People) return n.group as `group`,count(n) as `num`")
    List<Map<String,Object>> findGroupByNum();
}

But I encounter an error saying Records with more than one value cannot be converted without a mapper.
How can I solve this problem?

2 REPLIES 2

What you are trying to do is not possible with Spring Data Neo4j repositories. Their purpose is to interact on the entity abstraction and not with arbitrary data like String and Long combined into a map.
But there is a solution to this also in Spring Data Neo4j: The Neo4jClient (Neo4jClient Documentation)
For your example this would be something like:

Collection<Map<String, Object>> all = neo4jClient
        .query("match (n:People) return n.group as `group`,count(n) as `num`")
		.fetch().all();

And if you want to return (SDN-known) nodes and combine that, there is also a way: Mapping nodes in Neo4jClient result

OK.I will use the Neo4jClient.
Thank you for your help.