У меня есть следующая Spring Data Neo4j 4.2.0.BUILD-SNAPSHOT сущность:Spring Data Neo4j возвращает узел с пустыми дочерними узлами
@NodeEntity
public class VoteGroup extends BaseEntity {
private static final String VOTED_ON = "VOTED_ON";
private final static String VOTED_FOR = "VOTED_FOR";
@Relationship(type = VOTED_FOR, direction = Relationship.OUTGOING)
private Decision decision;
@Relationship(type = VOTED_ON, direction = Relationship.OUTGOING)
private Criterion criterion;
...
}
@NodeEntity
public class Decision extends Commentable {
@Relationship(type = VOTED_FOR, direction = Relationship.INCOMING)
private Set<VoteGroup> voteGroups = new HashSet<>();
...
}
@NodeEntity
public class Criterion extends Authorable {
@Relationship(type = VOTED_ON, direction = Relationship.INCOMING)
private Set<VoteGroup> voteGroups = new HashSet<>();
....
}
хранилище:
@Repository
public interface VoteGroupRepository extends GraphRepository<VoteGroup> {
@Query("MATCH (d:Decision)<-[:VOTED_FOR]-(vg:VoteGroup)-[:VOTED_ON]->(c:Criterion) WHERE id(d) = {decisionId} AND id(c) = {criterionId} RETURN vg")
VoteGroup getVoteGroupForDecisionOnCriterion(@Param("decisionId") Long decisionId, @Param("criterionId") Long criterionId);
}
Я создаю VoteGroup
с следующий конструктор:
public VoteGroup(Decision decision, Criterion criterion, double avgVotesWeight, long totalVotesCount) {
this.decision = decision;
decision.addVoteGroup(this);
this.criterion = criterion;
criterion.addVoteGroup(this);
this.avgVotesWeight = avgVotesWeight;
this.totalVotesCount = totalVotesCount;
}
, но когда я пытаюсь найти сохраненный ранее VoteGroup
с:
VoteGroup voteGroup = getVoteGroupForDecisionOnCriterion(decision.getId(), criterion.getId());
мой voteGroup.decision
и voteGroup.criterion
являются NULL ..
, но если я позвоню сразу же после этого findOne
метода:
voteGroup = voteGroupRepository.findOne(voteGroup.getId());
voteGroup.decision
и voteGroup.criterion
заполняются правильно.
Что не так с моим методом репозитория/Cypher и как его исправить?