Reputation: 341
Is there a way to ask for a result to be sorted but not paginated ?
I have this:
public interface SampleRepository extends PagingAndSortingRepository<Sample, Integer> {
}
but when calling http://localhost:8080/data/samples?sort=name,desc
the result is automatically paginated, but I do not want it paginated.
Upvotes: 0
Views: 3991
Reputation: 3169
PagingAndSortingRepository offers the Iterable<T> findAll(Sort sort)
method, that Returns all entities sorted by the given options.
Simply declare your SampleRepository
like this:
public interface SampleRepository extends PagingAndSortingRepository<Sample, Integer> {
List<Sample> findAll(Sort sort)
}
That's what JpaRepository does, for instance.
http://localhost:8080/data/samples?sort=name,desc
should then be mapped against SampleRepository.findAll(Sort sort)
and beahve as you want it to.
If it's not the case, you can also add a findBy* method:
@RestResource(path = "asList", rel = "asList")
public List<Sample> findAllAsList(Sort sort);
and call http://localhost:8080/data/samples/search/asList/samples?sort=name,desc
Upvotes: 1