我知道我可以编写以下代码来将我的查询限制为前1个结果:
Foo findTopByOrderByTimestampDesc();并将以下内容限制为前20个结果:
List<Foo> findTop20ByOrderByTimestampDesc();我也可以这样做:
Page<Foo> findAll(new PageRequest(0, 20, new Sort(Direction.DESC, "timestamp")));是否可以使用findTop样式的方法名来完成相同的任务?类似于:
List<Foo> findTopNByNOrderByTimestampDesc(int n); // this doesn't work谢谢!!
发布于 2018-03-12 04:59:26
下面是什么:
findAllOrderByTimestampDesc(Pageable pageable)然后像这样使用它:
repository.findAllOrderByTimestampDesc(new PageRequest(0, 20));https://stackoverflow.com/questions/49224561
复制相似问题