【发布时间】:2020-12-21 10:16:06
【问题描述】:
我正在尝试在我的 Reactive WebFlux 应用中实现分页,而我的数据库是 Couchbase。
The Spring Data Couchbase doc 允许我在我的存储库中将 Pageable 作为参数传递。
Flux<Person> findByFirstnameOrderByLastname(String firstname, Pageable pageable);
但是,当我尝试实现它时,我收到以下错误:
Caused by: java.lang.IllegalStateException: Method has to have one of the following return types! [interface org.springframework.data.domain.Slice, interface java.util.List, interface org.springframework.data.domain.Page]
我的存储库方法如下所示:
Flux<Building> findAll(Pageable pageable);
但是,如果我使用此解决方法,我没有问题。
@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} LIMIT $1 OFFSET $2")
Flux<Building> findAll(Integer limit, Integer offset);
这是一个错误吗?还是我用错了?
Spring Boot 版本:2.2.7.RELEASE
完整存储库:
@Repository
public interface BuildingRepository extends ReactiveSortingRepository<Building, String> {
@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} LIMIT $1 OFFSET $2")
Flux<Building> findAll(Integer limit, Integer offset);
//This works if I comment the below
Flux<Building> findAll(Pageable pageable);
}
【问题讨论】:
标签: spring-data couchbase spring-webflux spring-data-couchbase spring-reactive