英文:
Pageable attribute size value does not take effect
问题
以下是您要翻译的内容:
我有一个端点,其中除了其他属性之外,它还需要一个可分页对象。
众所周知,可分页对象有三个属性(页码、大小、排序)。
虽然前两个属性运行良好,我可以通过更改它们的值来操纵返回的结果列表,但排序属性却没有任何效果。
这是我的查询:
http://localhost:8080/api/social/msg/?socialRef=general&fromDate=2020-07-29T22:00:00.000Z&toDate=2020-08-10T14:42:13.325Z&page=0&size=1000&sort=createdAt,desc
端点代码如下:
public PaginatedCollection<SocialMsg> CustomCollectionListAll(Pageable pageable, Date lastModifiedBefore, Date lastModifiedAfter, String socialRef)
return socialService.messages().listAll(toPageableVO(pageable), lastModifiedBefore, lastModifiedAfter, socialRef);
英文:
I have an endpoint that amongst other attributes it takes a Pageable.
As known, pageable has three attributes(page, size, sort).
While the first two attributes work fine and I can manipulate the returned list of results by changing their values, the sort attribute doesnt take any effect.
This is my query:
http://localhost:8080/api/social/msg/?socialRef=general&fromDate=2020-07-29T22:00:00.000Z&toDate=2020-08-10T14:42:13.325Z&page=0&size=1000&sort=createdAt,desc
And the endpoint code:
public PaginatedCollection<SocialMsg> CustomCollectionListAll(Pageable pageable, Date lastModifiedBefore, Date lastModifiedAfter, String socialRef)
return socialService.messages().listAll(toPageableVO(pageable), lastModifiedBefore, lastModifiedAfter, socialRef);
答案1
得分: 1
请确保createdAt
是您的类中由Jpa使用的字段,并且其类型实现了Comparable接口。
英文:
Make sure that createdAt
is a field of your class used by Jpa, and that its Type implements Comparable
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论