小编Man*_* Ch的帖子

在Springboot中排序不适用于Pageable

我正在尝试通过在Springboot,JPARepository中使用Pageable来实现分页和排序。排序不起作用。我在下面包含我的代码的地方有控制器,服务类,存储库,实体等。我还发布了控制台输出,您可以在其中看到仅对SQL查询附加限制,但不附加“ order by”。我不知道我在这里缺少什么,因为我已经按照Spring.io中的记录进行了分页和排序。

TestController:

    @RestController
    @RequestMapping("/test")
    public class TestController {

        @Autowired
        private TestService testService;

        @GetMapping("/list/{fileId}")
        public Page<Test> list(@PathVariable Integer fileId, @RequestParam Map<String, String> queryMap) throws Exception {
            return testService.getTestList(fileId, queryMap);
        }

    }
Run Code Online (Sandbox Code Playgroud)

测试实体:

public class Test implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @NotNull
    @Column(name = "id")
    private Integer id;

    @Column(name = "fileId")
    private Integer fileId;

    @Column(name = "fname")
    private String fname;

    @Column(name = "lname")
    private String lname;

    @Column(name = "email")
    private String email;

    @Column(name = …
Run Code Online (Sandbox Code Playgroud)

sorting pagination spring-data-jpa spring-boot

5
推荐指数
1
解决办法
693
查看次数