Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-08-2022 06:45 AM
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?
04-12-2022 12:29 AM
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
04-12-2022 02:29 AM
OK.I will use the Neo4jClient.
Thank you for your help.
All the sessions of the conference are now available online