我有一个Person节点和一个呼叫关系。我想找到一个特定的人以及给他打电话的人。我的代码如下
@NodeEntity
public class Person extends BaseEntity{
@Property(name = "id")
private String mobile;
private String name;
private int partition;
private int StronglyConnectedComponents;
private int ConnectedComponent;
private int LabelPropagation;
private double pagerank;
private int seed_label; //在线算法结果写回字段
@Relationship(type="Call",direction=Relationship.OUTGOING)
private List<Person> contact;
//setter and getter
}
@RelationshipEntity(type = "Call")
public class Call extends BaseEntity{
@StartNode
private Person caller;
@EndNode
private Person callee;
private String BS;
private String time;
//setter and getter
}
@Repository
public interface PersonRepository extends GraphRepository<Person>{
Person findById(String id, @Depth int depth);
}
public String test() {
Person person = community.personRepository.findById("18565124452",2);
return person.toString();
}
使用测试方法,我可以检索人员节点的属性,但是关系属性contact为空。我该如何解决?
看起来像一个较旧的Spring Data Neo4j版本。但这在这里应该不是问题。在您的个人课程中,您正在定义
我在存在空关系时也遇到了同样的问题。我认为获取关系的唯一方法是使用密码查询语言。纠正meistermeir指出的错误。尝试将此方法添加到您的存储库类。