【问题标题】:Spring Slice Specification Pagable弹簧片规格可分页
【发布时间】:2021-01-14 14:06:05
【问题描述】:

我想将 Slice 与 Specification 和 Pagable 一起使用;不是列表或页面。 以下在 JpaRepository 中工作:

public interface PersonRepository extends JpaRepository<Person, UUID>,
    JpaSpecificationExecutor<Person> {

    Slice<Person> findAllBy(Pageable pageable);
}

但是如果我添加一个规范,至少提供了 1 个参数,它将失败:

Slice<Person> findAllBy(Specification<Person> specification, Pageable pageable);
java.lang.IllegalArgumentException: At least 1 parameter(s) provided but only 0 parameter(s) present in query.

【问题讨论】:

  • 你的仓库是否实现了JpaSpecificationExecutor
  • 是的。我更新了问题。
  • 很好,你能添加你得到的错误吗?
  • java.lang.IllegalArgumentException: 至少提供了 1 个参数,但查询中只存在 0 个参数。

标签: spring spring-boot spring-data-jpa


【解决方案1】:

Spring Data JPA 目前不支持此功能。见https://github.com/spring-projects/spring-data-jpa/issues/1311

您必须创建一个自定义方法来实现这一点。

【讨论】:

    猜你喜欢
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-20
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多