spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
923 stars 562 forks source link

default sort doesn't work [DATAREST-82] #467

Open spring-projects-issues opened 11 years ago

spring-projects-issues commented 11 years ago

Alexei Guevara opened DATAREST-82 and commented

When creating a repository that extends PagingAndSortingRepository the method PagingAndSortingRepository.findAll(Sort sort) is not recognized as a sort method when the user hits the url ".../entities?sort=name&name.dir=asc

The root cause of the problem is in the class RepositoryMethodInvoker.

Line 50 of RepositoryMethodInvoker reads as:

boolean someMethod = (null != paramType && Iterable.class.isAssignableFrom(paramType));

Which causes the method PagingAndSortingRepository.findAll(Sort sort) to be categorized as "someMethod" because Sort implements Iterable.

As a result the code in line 67

findAllSorted = repoMethod;

is never triggered because the code in line 65 takes precedence

findSome = repoMethod;


Affects: 1.1.0.M1

Referenced from: commits https://github.com/spring-projects/spring-data-rest/commit/462adb5a79ddea57db0e56d98380e7c8f68c1c58, https://github.com/spring-projects/spring-data-rest/commit/f60219480ff4caf8d9072e47cf2c25b01ba8e6e9

spring-projects-issues commented 11 years ago

Florent Biville commented

Hi, first time here, so sorry in advance if I ask silly questions. This seems to have been fixed in master by 462adb5a79ddea57db0e56d98380e7c8f68c1c58. Is there any reason why this ticket remains open?

Cheers, Flo