2

I'm trying to introduce Pageable support for my custom Cyper query over SDN 4 Repository method:

@Query(value = "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", countQuery="MATCH (parentD)-[:CONTAINS]->(childD:Decision) WHERE id(parentD) = {decisionId} RETURN count(childD)")
Page<WeightedDecision> getChildDecisionsSortedBySumOfCriteriaAvgVotesWeight(@Param("decisionId") Long decisionId, @Param("criteriaIds") Set<Long> criteriaIds, Pageable pageable);

WeightedDecision is a @QueryResult:

@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;
    }

}

Right now this logic fails with a ClassCastException exception:

java.lang.ClassCastException: com.example.domain.model.decision.result.WeightedDecision cannot be cast to org.springframework.data.domain.Page

What am I doing wrong and how to fix it ?

Luanne
  • 19,145
  • 1
  • 39
  • 51
alexanoid
  • 24,051
  • 54
  • 210
  • 410

1 Answers1

4

Version 2.0.4 of SDN did not support paging for @QueryResults. Version 2.0.5 will support this, and the feature is available for UAT in the snapshot build repository.

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • I'd like to confirm that it is working now with OGM 2.0.5-SNAPSHOT and SDN 4.2.0-BUILD-SNAPSHOT. Thanks !!! – alexanoid Aug 04 '16 at 10:28