Neo4j SDN 预填充实体

Neo4j SDN prepopulate entity

我有以下 Neo4j SDN 实体:

@NodeEntity
public class Comment {

    private final static String COMMENTED_ON = "COMMENTED_ON";
    private final static String CREATED_BY = "CREATED_BY";

    @RelatedTo(type = COMMENTED_ON, direction = Direction.OUTGOING)
    private Commentable commentable;

    private String text;

    @RelatedTo(type = CREATED_BY, direction = Direction.OUTGOING)
    private User author;

}

和以下 SDN 存储库方法:

@Override
@Query("MATCH (c:Comment) WHERE id(c) = {commentId} RETURN c")
Comment findOne(@Param("commentId") Long commentId);

作为此方法调用的结果,我只有 Comment 个对象 author.id

如何更改此方法(或 Cypher 查询)以便也预填充 author.name

您要么必须用 @Fetch 注释作者字段(这会急切地获取完整的作者。

或者您可以根据需要致电 template.fetch(comment.author)