I wanted to get the last 5 entries of an entity. But you cannot get it through Spring Data JPA.
I originally tried to get data through a LIMIT request, but LIMIT is not supported in JPA.
Later I tried with the Pageable interface.
Pageable pageCount = new PageRequest(0, 10, Direction.ASC,"id"); List<TxnEntity> txnEntities = txnDAO .findByAccountEntity(accountEntity,pageCount);
This gives me the first page with 10 objects.
But my requirement is to get the last 10 or 5 objects. So, how can I get it through the Pageable interface within Spring?
java spring hibernate jpa
virsha
source share