Hello, I'm having an issue with deserializing a simple query using a Neo4JRepository in an example I wrote.
PersonRepository has the following method signature:
public interface PersonRepository extends Neo4jRepository<Person, String> {
...
@Query( "MATCH (p:Person{name: $pName})-[:LOCATED_IN]-(a:Address)" +
"MATCH (p:Person)-[:HAS]-(w:Wealth)" +
"MATCH (p:Person)-[s:STUDIED_IN]-(o:Organization)" +
"RETURN p.id AS id, a AS address, w AS wealth, s AS education")
Collection<PersonDetails> getPersonDetails(@Param("pName") String personName);
The PersonDetails result object looks like this:
@Value
public class PersonDetails {
String id;
Address address;
Wealth wealth;
Collection<StudiedIn> education;
}
Address and Wealth are entities also annotated as @Value.
StudiedIn Looks like this:
@Value
@RequiredArgsConstructor
@RelationshipProperties
public class StudiedIn {
@Id
@GeneratedValue
private Long id;
private final String degree;
private final int year;
@TargetNode
private final Organization organization;
}
When I use the method, I get the following error:
2021-03-09 16:31:05.057 DEBUG 15888 --- [nio-8888-exec-3] org.springframework.data.neo4j.cypher : Executing:
MATCH (p:Person{name : $pName})-[:LOCATED_IN]-(a:Address)MATCH (p:Person)-[:HAS]-(w:Wealth)MATCH (p:Person)-[s:STUDIED_IN]-(o:Organization)RETURN p.id AS id, a AS address, w AS wealth, s AS education
2021-03-09 16:31:05.085 WARN 15888 --- [nio-8888-exec-3] .r.s.Neo4jPersistenceExceptionTranslator : Don't know how to translate exception of type class org.springframework.data.neo4j.core.mapping.NoRootNodeMappingException
2021-03-09 16:31:05.086 DEBUG 15888 --- [nio-8888-exec-3] o.s.web.servlet.DispatcherServlet : Failed to complete request: org.springframework.data.neo4j.core.mapping.NoRootNodeMappingException: Could not find mappable nodes or relationships inside Record<{id: "0220682345", address: node<165>, wealth: node<164>, education: relationship<292>}> for org.springframework.data.neo4j.core.mapping.DefaultNeo4jPersistentEntity@6c8d8b60
Do I explicitly need to map the result with the type? I understood that was implicit because of the Repository method signature definition. Surely I'm missing something else. Could you help me with this?