JHipster generated entity list pagination without enforced maximum page size
0 reputation · 15 Oct 2021, 02:26 UTC
0 reputation · 15 Oct 2021, 02:26 UTC
JHipster scaffolds Spring Data JPA repositories and REST resources that expose list endpoints with Spring Data Pageable. The generated methods accept page, size and sort query parameters and return org.springframework.data.domain.Page, which is translated by JPA/Hibernate to LIMIT/OFFSET SQL.
The goal is to bound queries over a large dataset and keep pagination predictable. The generated code relies on spring.data.web.pageable defaults for default page size and sort, and no generator-provided global cap on page size is applied by default. Clients can therefore request arbitrarily large sizes unless a custom PageableHandlerMethodArgumentResolver or interceptor is added. Permission boundaries for who may request larger pages are not generated.
Offset-based pagination degrades with deep pages and unbounded size can increase memory and database load. Pagination defaults and property names are version-sensitive across JHipster major releases.
What mechanism is available in a generated application to enforce a global maximum page size? How is the default page size determined for the generated entity list endpoints? Is there a generated permission boundary that restricts larger page sizes to specific roles?
35775 reputation · 15 Oct 2021, 05:40 UTC
JHipster scaffolds Spring Data JPA repositories and REST resources that expose list endpoints with Spring Data Pageable. The generated methods accept page, size and sort query parameters and return org.springframework.data.domain.Page, which JPA/Hibernate translates to LIMIT/OFFSET SQL. By default, no global maximum page size is enforced, and clients can request arbitrarily large sizes unless the application configuration provides a cap.
JHipster delegates pagination behavior to Spring Data Web. The generator provides repository and resource scaffolding but does not configure global pagination bounds or role-based size limits, relying on the application developer to add them.
Diagnostic detail that changes the recommendation: JHipster and Spring Boot version. Property names and defaults are version-sensitive across JHipster major releases, and a JHipster-specific pageable property may exist in newer versions. Could you confirm the JHipster version in use?
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 15 Oct 2021, 06:29 UTC
JHipster scaffolds Pageable endpoints without a generated cap. The default page size comes from Spring Data Web properties, typically spring.data.web.pageable.default-page-size which JHipster sets to 20 in application.yml. No spring.data.web.pageable.max-page-size is generated, so the resolver’s max remains 0 = unlimited.
There is no generated permission boundary that restricts size by role. Any caller allowed to hit the resource can request any size; role-gated clamping requires a custom PageableHandlerMethodArgumentResolver or interceptor.
Verification: inspect config for default-page-size and absence of max-page-size, then request ?size=10000 on a generated list endpoint. Adding max-page-size in application.yml is the standard Spring Boot way to enforce a global cap.