0
노드에 대한 열망로드 관계 :Neo4j - 나는 이런 NodeEntity이
@NodeEntity
public class User {
@GraphId
private Long id;
private String name;
@Fetch
@RelatedToVia
private Set<Rel> rels;
public Rel connectTo(User u, String type) {
if (this.rels == null)
this.rels = new HashSet<Rel>();
Rel rel = new Rel(this, u, type);
this.rels.add(rel);
return rel;
}
}
과 RelationshipEntity :
@RelationshipEntity(type="REL")
public class Rel {
@GraphId
private Long id;
@Fetch
@StartNode
private User start;
@Fetch
@EndNode
private User end;
@RelationshipType
private String type;
public Rel(){}
public Rel(User start, User end, String type) {
this.start = start;
this.end = end;
this.type = type;
}
}
하지만 사용자를로드 할 때, 관계가 비어를 :
User neo = new User();
neo.setName("Neo");
User trinity = new User();
trinity.setName("Trinity");
this.userRepository.save(trinity);
neo.connectTo(trinity, "LOVES");
this.userRepository.save(neo);
User user = this.userRepository.findOne(neo.getId());
// expected:<1> but was:<0>
Assert.assertEquals(1, user.getRels().size());
이 노드와 관련된 관계를 어떻게로드 할 수 있습니까? 어떻게 놓쳤습니까?
미리 감사드립니다.