Spring Data Neo4j 4 和 Pageable @QueryResult [英] Spring Data Neo4j 4 and Pageable @QueryResult

查看:62
本文介绍了Spring Data Neo4j 4 和 Pageable @QueryResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 SDN 4 Repository 方法为我的自定义 Cyper 查询引入 Pageable 支持:

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 是一个 @QueryResult:

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

}

现在这个逻辑失败,出现一个 ClassCastException 异常:

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 ?

推荐答案

SDN 2.0.4 版不支持@QueryResults 的分页.2.0.5 版支持此功能,该功能可用于快照构建存储库中的 UAT.

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.

这篇关于Spring Data Neo4j 4 和 Pageable @QueryResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆