簡體   English   中英

為什么 Jpa 排序不適用於 Spring 中的 Pageable?

[英]Why Jpa sorting is not working with Pageable in Spring?

分頁工作正常,但我無法根據特定字段對數據進行排序。 我的存儲庫方法Page<AdvertSearch> findAll(Pageable pageable);

我的實體 class 是:

public class AdvertSearch {

    @Id
    @GeneratedValue(generator = "uuid2")
    @GenericGenerator(name = "uuid2", strategy = "uuid2")
    @Column(name = "id", nullable = false, columnDefinition = "VARCHAR(36)")
    private String id;

    private String advertId;
    private String officeId;
    private String officeName;

    //TODO: type hangi Point olacak hangi class olacak karar verilecek
    @Column(nullable = false, columnDefinition = "POINT SRID 4326")
    private Point location;

    private OfficeType officeType;
    private String city;
    private String district;
    private String mainOfficeId;
    private Integer facilityCount;
    private Integer virtualPackageCount;
    private BuildingType buildingType;
    private Integer securityCount;
    private Double monthlyPrice;
    private String currency;
    private Integer capacity;

    //TODO: officelerde rating olmayacak diye konustuk bunun da netlestirilmesi gerek
    private Double rating;
    private Integer ratingCount;
}

我的 postman 請求是: http://localhost:8080/advertsearch/findallbypage?page=0&size=4&sort=district&direction=desc

在此處輸入圖像描述

如您所見,我想根據地區對數據進行排序,但它不起作用。 我的要求錯了嗎? 還是關於 JPA 中的Pageable

方向應該在排序參數中:

?page=0&size=4&sort=district,desc

您可以在此處找到更多示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM