【问题标题】:Spring Data Neo4j 4 and Pageable @QueryResultSpring Data Neo4j 4 和可分页的@QueryResult
【发布时间】:2016-08-01 07:16:50
【问题描述】:

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

@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 异常而失败:

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

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

【问题讨论】:

  • 将此问题复制为 OGM(或 SDN,更确切地说)中的错误。正在修复。会及时通知您。

标签: neo4j cypher spring-data-neo4j-4


【解决方案1】:

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

【讨论】:

  • 我想确认它现在正在使用 OGM 2.0.5-SNAPSHOT 和 SDN 4.2.0-BUILD-SNAPSHOT。谢谢!!!
猜你喜欢
  • 2014-01-01
  • 2015-08-17
  • 2017-05-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多