Ich habe eine folgende Spring Data Neo4j 4.2.0.BUILD-snapshot Einheiten:Spring Data Neo4j kehrt Knoten mit leeren Kindknoten
@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:
@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);
}
Ich schaffe VoteGroup
mit ein folgender Konstruktor:
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;
}
aber wenn ich versuchezuvor gespeicherte zu findenmit:
VoteGroup voteGroup = getVoteGroupForDecisionOnCriterion(decision.getId(), criterion.getId());
meine voteGroup.decision
und voteGroup.criterion
sind NULL ..
aber wenn ich direkt nach dem findOne
Methode aufrufen:
voteGroup = voteGroupRepository.findOne(voteGroup.getId());
voteGroup.decision
und voteGroup.criterion
richtig ausgefüllt.
Was ist falsch mit meiner Repository-Methode/Cypher und wie man es beheben kann?