I'm getting org.neo4j.ogm.metadata.MappingException: Infinite recursion (StackOverflowError) while performing a repository query. The project was ported from SDN 3.
Sample domain models:
@NodeEntity
public class Person {
...
@Relationship(type = "FRIENDSHIP")
private Set<Friendship> friendships = new HashSet<Friendship>();
...
}
@RelationshipEntity
public class Friendship {
...
@StartNode private Person person1;
@EndNode private Person person2;
Date since;
...
}
The exception is thrown when the following query is run:
@Query("MATCH (person1 {id: {0}.id})-[rel:FRIENDSHIP]->(person2 {id: {1}.id}) "
+ "return rel")
Friendship getFriendship(Person person1, Person person2);
Exception:
org.neo4j.ogm.metadata.MappingException: Infinite recursion (StackOverflowError) (through reference chain: com.example.domain.Friendship["person1StartNode"]->com.example.domain.Person["friendships"]->java.util.HashSet[0]->com.example.domain.Friendship["niperson1StartNode"]->com.example.domain.Person["friendships"]......
I thought this might be to do with @StartNode and @EndNode being the same type. But I got the same exception when @EndNode was of some other type.
Working with snapshots.
Could you please change the query to
@Query("MATCH (person1 {id: {0}})-[rel:FRIENDSHIP]->(person2 {id: {1}}) "
+ "return rel")
Friendship getFriendship(long person1, long person2);
(or the correct datatype of id
)
Parameters that are entities themselves are not supported.
Having said that, the exception isn't helpful at all. Opened https://jira.spring.io/browse/DATAGRAPH-694