@NodeEntity
public class Person {
@GraphId private Long nodeId;
private String name;
private String addr;
private int age;
@Relationship(type="WATCH")
private Set<Movie> movies;
}
@NodeEntity
public class Movie{
@GraphId private Long nodeId;
private String title;
private int released;
@Relationship(type="WATCH" ,direction = Relationship.INCOMING)
private Person person;
public Movie(){}
}
@RequestMapping(value = "/movieTest", method = RequestMethod.GET)
public Movie movieTest(){
Movie movie =movieRepository.findOne(5078L,1);
return movie;
}
public interface MovieRepository extends GraphRepository<Movie> {
}
I create a Person class and a Movie class ,Person "WATCH" Movie,Person has property "movies",and Movie has property "person",My purpose is to get Person by a movie id,but an "java.lang.StackOverflowError" exception happened when I call /movieTest API,because after findOne() executed , the result object movie has a sub-object person, and person has a sub-object movies ,then go to a endless loop, so what I wonder is how to deal this situation or what should I do when I need to get Person By a movie id?