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