I'm using spring-data-rest with JpaRepository
to create the Rest-Endpoints. By default, paging is enabled for all JpaRepository
, what is a good thing. But I have a legacy application that we port to our new stack that does not support paging. I would like to disable paging depending on an URL-Parameter to still be able to use paging in new application code.
I tried various approaches to expose the resources with and without paging:
- Use
CrudRepository
: Results in only having an unpaged endpoint and the methodflush
is missing. - Override the
List<T> findAll()
method in my repository interface and annotated it withRestResource
. I would have expected that the method will be exposed as search method, but it is not. - Annotate
Page<T> findAll(Pageable pageable)
with@RestResource(exported=false)
and annotateList<T> findAll()
as in the bullet before. I have hopped that this replaces the default method. But this is not valid solution anyway, because only a non paged endpoint is exposed. - Pass
size=-1
to get an unlimited result -> Default paging size is used
I've seen that the spring-controller RepositoryEntityController
uses a RepositoryInvoker
to call the methods on the repository. The Pageable
is resolved using the PageableHandlerMethodArgumentResolver
which always returns a pageable (specified in query, annotated or default pageable).
The only solution that I see for the moment is to implement a custom PageableHandlerMethodArgumentResolver
that returns null, if a custom url parameter is passed.
Do you know any other solutions or is anything similar planned for the future?