节点和关系:
@NodeEntity
public class User {
@GraphId
private Long id;
@Relationship(type = "WATCHED", direction = Relationship.OUTGOING)
private Set<Watched> watchedList = new HashSet<>();
@Relationship(type = "WATCHED", direction = Relationship.OUTGOING)
public Set<Watched> getWatchedList() {
return watchedList;
}
}
@NodeEntity
public class Movie {
@GraphId
private Long id;
@Relationship(type = "WATCHED", direction = Relationship.INCOMING)
private Set<Watched> watchedList = new HashSet<>();
@Relationship(type = "WATCHED", direction = Relationship.INCOMING)
public Set<Watched> getWatchedList() {
return watchedList;
}
}
@RelationshipEntity(type = "WATCHED")
public class Watched {
@GraphId
private Long id;
@StartNode
private User user;
@EndNode
private Movie movie;
private Date date;
private String comment;
...
}
图表示例: 7 WATHCED links
当我与用户尝试这样的事情:“user.getWatchedList()。size()”因为watchedList为空,结果为0。
但是,如果我之前执行类似“watchedRepository.findAll()”的操作,列表会正确加载。
有什么想法吗?