gpt4 book ai didi

java - 如何使用带注释的查询让 PageRequest 在 Spring Boot 中工作

转载 作者:行者123 更新时间:2023-12-02 01:39:41 25 4
gpt4 key购买 nike

我正在从 Spring Boot 1 升级到 Spring Boot 2。

我试图仅选取第一个结果。

PageRequest pageRequest = PageRequest.of(0, batchSize, Sort.Direction.ASC, "id");

在存储库上使用带注释的查询

@Query("select c from Component")
List<Component> findReturnComponent(PageRequest pageRequest);

我收到此错误消息

but parameter 'Optional[pageRequest]' not found in annotated query 'select c from Component

最佳答案

使用可分页接口(interface)代替 PageRequest

Pageable pageable = PageRequest.of(0, batchSize, Sort.Direction.ASC, "id");

@Query("select c from Component")
List<Component> findReturnComponent(Pageable pageable);

关于java - 如何使用带注释的查询让 PageRequest 在 Spring Boot 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54620809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com