我得到org.neo4j.ogm.metadata.MappingException:無限遞歸(StackOverflowError)執行存儲庫查詢時。該項目是由SDN 3.SDN 4 - MappingException:無限遞歸(StackOverflowError)
樣域模型移植:
@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;
...
}
時,下面的查詢運行的異常被拋出:
@Query("MATCH (person1 {id: {0}.id})-[rel:FRIENDSHIP]->(person2 {id: {1}.id}) "
+ "return rel")
Friendship getFriendship(Person person1, Person person2);
例外:
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"]......
我認爲這可能與@StartNode和@EndNode是同一類型。但是當@EndNode是其他類型時,我得到了相同的異常。
使用快照。