alexanoid
alexanoid

Reputation: 25812

Spring Data Neo4j 4 and Pageable @QueryResult

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 ?

Upvotes: 2

Views: 736

Answers (1)

Jasper Blues
Jasper Blues

Reputation: 28766

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.

Upvotes: 4

Related Questions