neo4j - Spring Data Neo4j 4 和 Pageable @QueryResult

标签 neo4j cypher spring-data-neo4j-4

我想介绍 Pageable支持我通过 SDN 4 Repository 方法的自定义 Cyper 查询:

@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:
@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异常(exception):
java.lang.ClassCastException: com.example.domain.model.decision.result.WeightedDecision cannot be cast to org.springframework.data.domain.Page

我做错了什么以及如何解决?

最佳答案

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

关于neo4j - Spring Data Neo4j 4 和 Pageable @QueryResult,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38692985/

相关文章:

java - 社交网络架构、C++ Clients Neo4j 数据库之间有什么关系?

neo4j - 如何在 Neo4j Desktop 中重命名新项目?

java - 密码查询 : - Allow apostrope(') containing String in the query

java - 如何设置约束来限制单个节点上特定类型的关系数量

neo4j - 如何在 Neo4j 中创建数十亿个节点?

java - Spring 数据 Neo4j 4.0.0 : Can't Create Relationship Between Nodes with the Same Label

java - 如何编写 @QueryResult 类以正确捕获密码结果。 (未经反复试验)

java - 在 Java 中执行 Neo4j Cypher 查询时出现 NoClassDefFoundError

java - MissingMethodException - org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl.createNode() - Groovy

neo4j - 使用 Spring Data Neo4j 4 更新简单对象关系的目标不会产生预期结果