title: Sort Not Working - Accessing Data with JPA
body: <p>I've been playing with the Spring "Accessing Data with JPA" starter, adding my own entity and the corresponding repository.</p>
  
  <pre><code>@RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
  @CrossOrigin(maxAge = 3600)
  public interface OrderRepository extends PagingAndSortingRepository&lt;Order, Long&gt; {
  </code></pre>
  
  <p>The controllerless routes work fine for simple paging, but there is nothing I can do to get sorting working. </p>
  
  <p>There are two cases. One:</p>
  
  <pre><code>http://192.168.0.163:8080/orders?sort=order_id&amp;order_id.dir=desc
  </code></pre>
  
  <p>In this case the sort argument has no effect. No matter what combination I try, the sort order is unaffected. I have turned on show queries in STS, and no "order by" clause is generated.</p>
  
  <p>The second case is for some field names in sort=, there is a null pointer exception in Spring:</p>
  
  <pre><code>2016-10-07 14:32:48.426 DEBUG 8292 --- [nio-8080-exec-8] .w.s.m.m.a.ServletInvocableHandlerMethod : Error resolving argument [1] [type=org.springframework.data.rest.webmvc.support.DefaultedPageable]
  HandlerMethod details: 
  Controller [org.springframework.data.rest.webmvc.RepositoryEntityController]
  Method [public org.springframework.hateoas.Resources&lt;?&gt; org.springframework.data.rest.webmvc.RepositoryEntityController.getCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.support.DefaultedPageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.data.rest.webmvc.ResourceNotFoundException,org.springframework.web.HttpRequestMethodNotSupportedException]
  
  
  java.lang.NullPointerException: null
      at org.springframework.data.rest.webmvc.json.JacksonMappingAwareSortTranslator$SortTranslator.translateSort(JacksonMappingAwareSortTranslator.java:101) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
      at org.springframework.data.rest.webmvc.json.JacksonMappingAwareSortTranslator.translateSort(JacksonMappingAwareSortTranslator.java:70) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
      at org.springframework.data.rest.webmvc.json.MappingAwareDefaultedPageableArgumentResolver.resolveArgument(MappingAwareDefaultedPageableArgumentResolver.java:73) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
      at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  ...
  </code></pre>
  
  <p>I just downloaded STS and the starter this week so they should be the latest versions.</p>