【问题标题】:Neo4j SDN prepopulate entityNeo4j SDN 预填充实体
【发布时间】:2015-11-28 17:48:28
【问题描述】:

我有以下 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?

【问题讨论】:

    标签: java neo4j cypher spring-data-neo4j


    【解决方案1】:

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

    如果需要,您也可以致电template.fetch(comment.author)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多