gpt4 book ai didi

java - Neo4j SDN 预填充实体

转载 作者:行者123 更新时间:2023-11-30 07:45:48 25 4
gpt4 key购买 nike

我有一个以下 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);

作为此方法调用的结果,我仅拥有带有 author.idComment 对象。

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

最佳答案

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

或者,如果需要的话,您可以根据具体情况调用template.fetch(comment.author)

关于java - Neo4j SDN 预填充实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33974447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com