I have a table called "User and Review" in neo4j database. have to get those data from spring data neo4j. Here i do not want to get a modal. But I need a particular values. They are Id, message, rating etc. The problem is how to map those custom returned values from Db. please help me with it.
The sample query is:
@Query("MATCH (from:User)-[r:REVIEWED]->(to:User) where r.eventId={0} return ID(r),r.message,r.rating,r.eventId,r.zimId,from.firstName,to.firstName")
public List<ReviewRelatioshipDto> getReviewsByEventIdAndId(Long eventId);
Exception:
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/social] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: Scalar response queries must only return one column. Make sure your cypher query only returns one item.] with root cause
java.lang.RuntimeException: Scalar response queries must only return one column. Make sure your cypher query only returns one item.
There are two options- one is to use a @QueryResult
and therefore, ReviewRelationshipDto
must be annotated and follow JavaBean getter conventions or use @Property
.
The other option is to just return a Map of columns and values Iterable<Map<String,Object>>
where the key is the column alias and the value the column value.