SDN 4.1.2 rich @Relationship不会“预加载”Set <relationship>节点属性

时间:2017-03-08 19:39:52

标签: spring neo4j spring-data-neo4j sdn

节点和关系:

@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()”的操作,列表会正确加载。

有什么想法吗?

0 个答案:

没有答案