Case 1: Use Pageable on search methods of JPA repositories to avoid unused data retrieval
Rule complete description
Text
In many cases we only need to retrieve or display a subset of data and not all the data.
To avoid unneeded data retrieval, it's better to make paginated queries to the database.
Spring data has a Pageable feature implement by default by the JpaRepository which extends the PagingAndSortingRepository.
All calls to search methods should ase a Pageable argument to specify the size and the number of the current page, this must be done on find* methods on a JPA repository.
Interesting but difficult to be sure that the rule is energy efficient (no documentation or something else to justify). May be a rule to measure in the next hackaton.
\newpage
Best practice JPA repositories use
Platform
Main caracteristics
Severity / Remediation Cost
Rule short description
Rule complete description
Text
In many cases we only need to retrieve or display a subset of data and not all the data. To avoid unneeded data retrieval, it's better to make paginated queries to the database. Spring data has a Pageable feature implement by default by the JpaRepository which extends the PagingAndSortingRepository. All calls to search methods should ase a Pageable argument to specify the size and the number of the current page, this must be done on find* methods on a JPA repository.
JAVA Example
Implementation principle