Pageable属性size的值无效。

huangapple go评论86阅读模式
英文:

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&amp;fromDate=2020-07-29T22:00:00.000Z&amp;toDate=2020-08-10T14:42:13.325Z&amp;page=0&amp;size=1000&amp;sort=createdAt,desc

And the endpoint code:

public PaginatedCollection&lt;SocialMsg&gt; 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

huangapple
  • 本文由 发表于 2020年8月21日 23:42:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/63525945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定