Skip to content

Files

Latest commit

 

History

History

HibernateSpringBootPageEntityOffsetPaginationProjection

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Offset Pagination - Trigger SELECT COUNT Subquery And Return Page<projection> That Maps Entities And The Total Number Of Records Via Projection

Description: This application fetches data as Page<projection> via Spring Boot offset pagination. The projection maps the entity and the total number of records. This information is fetched in a single database rountrip because the SELECT COUNT triggered for counting the total number of records is a subquery of the main SELECT.

Key points:

  • define a Spring projection that maps the entity and the total number of records
  • write a repository that extends PagingAndSortingRepository
  • fetch data via a JPQL query into a List<projection>
  • use the fetched List<projection> and Pageable to create a Page<projection>

If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices"If you need a hand of tips and illustrations of 100+ Java persistence performance issues then "Java Persistence Performance Illustrated Guide" is for you.