Reputation: 567
What is the best way to go about defining @QueryResult classes? I have defined a repository method annotated with query like
"MATCH(p:Person{name:{0}) - [r]-(e)
RETURN distinct label(e) as type ,count(label(e)) as count;"
On neo4j console output looks like map.
type count
---- -----
Account 2
Document 5
Organization 4
So i have defined return type of the method like Map<String, Long>
but doesn't work. Then I tried other ways - it returns the counts combined not individual. now am planning to use java driver to solve this problem. What the best way to go about designing @QueryResult
to fit my situation. Any resources will be helpful along with the answer to my problem. :)
Upvotes: 0
Views: 459
Reputation: 1270
Your query should return count(e)
and not count(labels(e))
.
You can then use a org.neo4j.ogm.model.Result
to hold the results of your query :
@Query("MATCH(p:Person{lastName:{0}}) -[r]-(e) RETURN distinct labels(e) as type ,count(e) as count")
Result resultExample(String name);
Upvotes: 2