Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 根据时间戳递减检索最后100条记录_Database_Hibernate_Spring Mvc_Jpa_Spring Data - Fatal编程技术网

Database 根据时间戳递减检索最后100条记录

Database 根据时间戳递减检索最后100条记录,database,hibernate,spring-mvc,jpa,spring-data,Database,Hibernate,Spring Mvc,Jpa,Spring Data,我在数据库中有一个包含10000条记录的表,该表包含时间戳列我想根据时间戳降序检索最后100条记录我使用spring mvc和jpa存储库有人能帮我怎么做吗 在您的存储库中尝试类似的操作 List<MyEntity> findAllOrderByTimestampDesc(Pageable pageable); 列出findAllOrderByTimestampDesc(可分页); 那么,请用 int queryLimit = 100; List<MyEntity>

我在数据库中有一个包含10000条记录的表,该表包含时间戳列我想根据时间戳降序检索最后100条记录我使用spring mvc和jpa存储库有人能帮我怎么做吗

在您的存储库中尝试类似的操作

List<MyEntity> findAllOrderByTimestampDesc(Pageable pageable);
列出findAllOrderByTimestampDesc(可分页);
那么,请用

int queryLimit = 100;
List<MyEntity> queryResults = myRepository.findAllOrderByTimestampDesc(new PageRequest(0, queryLimit));
int queryLimit=100;
List queryResults=myRepository.findAllOrderByTimestampDesc(新页面请求(0,queryLimit));

这是一种很好的方法,但它得到了前100条记录我想检索最后100条记录必须将方法名称更改为
findAllOrderByTimestampAsc