In my SDN 4 project I have a @QueryResult
POJO:
@QueryResult
public class WeightedDecision {
private Decision decision;
private double weight;
public Decision getDecision() {
return decision;
}
public void setDecision(Decision decision) {
this.decision = decision;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
And a lot of Spring Data Neo4j repository methods that work fine with this WeightedDecision
query result.
Right now I'm trying to manually construct a Cypher query where I'm going to return the list of WeightedDecision
as a result.
I use following method for this purpose:
return (List<WeightedDecision>) session.query(WeightedDecision.class, cypher, parameters);
my Cypher query looks like:
MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} OPTIONAL MATCH (childD)<-[:VOTED_FOR]-(vg:VoteGroup)-[:VOTED_ON]->(c:Criterion) WHERE id(c) IN {criteriaIds} WITH childD, ru, u, vg.avgVotesWeight as weight RETURN childD AS decision, ru, u, sum(weight) as weight ORDER BY weight DESC
but the result of session.query
is empty in this case.
If I'm changing the session.query
method parameters to:
return (List<WeightedDecision>) session.query(Decision.class, cypher, parameters);
where Decision
is a Node Entity everything works fine and returns List of Decision.
How to get it working with a @QueryResult
type ?