0

everyone. I have a controller with Specification and Pageable parameters. If I need to return data form db in a usual way - everything works fine. I get my data by 20 size pages. Like this:

    ............
    "totalElements": 2612,
    "totalPages": 131,
    "last": false,
    "size": 20,
    "number": 0,

But also, I need to return all my elements. Acording to the example, if I get totalElements: 2612 - I want to get all 2612. As I understant, Spring has default max-page-size = 2000. Because of it, If I have a query with size = 2612

http://localhost:7038/api/get-journal/2c9a508179b2933a0179b2be69fd0003?yearReg=2023&page=0&size=2612

I get an answer :

    "totalElements": 2612,
    "totalPages": 2,
    "last": false,
    "size": 2000,

You can see, that instead of 2612, I have 2000 and two pages.

Similar problems didn't help me:

https://stackoverflow.com/questions/23751193/spring-data-jpa-limit-pagesize-how-to-set-to-maxsize

I've already tried to create ConfigClass or add into app.properties : spring.data.web.pageable.max-page-size=10000 or spring.data.web.pageable.max-page-size=10000

I use Spring Boot 2.3.3.

EDIT I get a changed variable even in my rest controller:

enter image description here

Vitaliy
  • 25
  • 7
  • Did you try the solution mentioned here? https://stackoverflow.com/questions/33675349/spring-data-rest-max-page-size-does-not-seem-to-be-working – Joan May 16 '23 at 12:59
  • @Joan, yes. It doesn't work. But thank you. – Vitaliy May 16 '23 at 13:47

1 Answers1

0

Thank you, guys. I've found a solution. I had a config class with following code:

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    argumentResolvers.add(new SpecificationArgumentResolver(abstractApplicationContext));
    argumentResolvers.add(new PageableHandlerMethodArgumentResolver());
}

You can see here

PageableHandlerMethodArgumentResolver

Which I tried to change. I think it was a problem why my other configuration classes didn't work. As I changed that code to:

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
    argumentResolvers.add(new SpecificationArgumentResolver(abstractApplicationContext));
    PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver = new PageableHandlerMethodArgumentResolver();
    pageableHandlerMethodArgumentResolver.setMaxPageSize(100_000);
    argumentResolvers.add(pageableHandlerMethodArgumentResolver);
}

Now everything works fine. Thanks again!

Vitaliy
  • 25
  • 7