我期望的输出是最后n条记录。
所以我用过Spring Data JPA 1.7内置查询
int n = 10;Pageable pageCount = new PageRequest(0, n);List<TxnEntity> txnEntities = txnDAO .findByAccountEntityOrderByIdDesc(accountEntity,pageCount);
现在,这将返回最后n条记录。
DAO将以降序返回所有记录,通过使用Pageable,我们可以从底部开始需要多少条记录。
很简单。
有关更多JPA查询的内置查询:http : //docs.spring.io/spring-
data/jpa/docs/current/reference/html/



