1
我从SDN 3移动到SDN 4和从Neo4j的2.3到3.0.1弹簧数据的Neo4j 4库方法返回1个元件
在新的依赖我的测试失败,并断言。它只返回一个,而不是3个节点。
@NodeEntity
public class Decision extends Commentable {
private final static String CONTAINS = "CONTAINS";
private final static String DEFINED_BY = "DEFINED_BY";
private final static String VOTED_FOR = "VOTED_FOR";
private String name;
@Relationship(type = DEFINED_BY, direction = Relationship.INCOMING)
private Set<Criterion> criteria = new HashSet<>();
....
@NodeEntity
public class Criterion extends Authorable {
private final static String CONTAINS = "CONTAINS";
private final static String DEFINED_BY = "DEFINED_BY";
private String name;
private String description;
@Relationship(type = CONTAINS, direction = Relationship.INCOMING)
private CriterionGroup group;
@Relationship(type = DEFINED_BY, direction = Relationship.OUTGOING)
private Decision owner;
@Test
public void testGetChildDecisionsSortedBySumOfCriteriaAvgVotesWeightWithCoefficients() {
User user = userService.createUser("test", "test", "[email protected]", null, null);
final Decision rootDecision1 = decisionDao.create("Root decision1", "Root decision 1 description", null, user);
final Criterion rootDecision1Criterion1 = criterionDao.create("rootDecision1Criterion1", "rootDecision1Criterion1", rootDecision1, user);
final Criterion rootDecision1Criterion2 = criterionDao.create("rootDecision1Criterion2", "rootDecision1Criterion2", rootDecision1, user);
final Criterion rootDecision1Criterion3 = criterionDao.create("rootDecision1Criterion3", "rootDecision1Criterion3", rootDecision1, user);
assertEquals(3, criterionDao.getCriteriaDefinedByDecision(rootDecision1.getId()).size());
库方法:
@Query("MATCH (d:Decision)<-[:DEFINED_BY]-(c:Criterion) WHERE id(d) = {decisionId} RETURN c")
List<Criterion> getCriteriaDefinedByDecision(@Param("decisionId") Long decisionId);
什么可以这个问题的原因,以及如何解决它?
修订
我发现施工
public Criterion(String name, String description, Decision owner, User author) {
this.name = name;
this.description = description;
this.owner = owner;
setAuthor(author);
}
是不够的,为了创造ONE_TO_MANY协会SDN 4 ..我要以添加对象父集合添加额外的行也。
public Criterion(String name, String description, Decision owner, User author) {
this.name = name;
this.description = description;
this.owner = owner;
if (owner != null) {
owner.addCriterion(this);
}
setAuthor(author);
}
我在做什么错?
谢谢,但我需要按照我的应用程序的业务逻辑这一领域。它在以前版本的SDN中完美运行..他们为什么要改变它? – brunoid
不知道,有同样的问题。 –