title: Passing List<Long> to Spring Data Repository as SDR Query Parameter
body: <p>I have the following interface which is extended by several of my repository interfaces:</p>
  
  <pre><code>public interface IdentifiableEntityRepository&lt;T, ID extends Serializable&gt; {
  
      @RestResource(path="findAll")
      public List&lt;T&gt; findByIdIn(@Param("ids") List&lt;ID&gt; ids);
  
  }
  </code></pre>
  
  <p>Here's an example of a repository that happens to have String IDs:</p>
  
  <pre><code>public interface FooRepository extends IdentifiableEntityRepository&lt;Foo, String&gt;, 
          PagingAndSortingRepository&lt;Foo, String&gt; 
  {
      ...
  }
  </code></pre>
  
  <p>... and another example that happens to have Long IDs:</p>
  
  <pre><code>public interface BarRepository extends IdentifiableEntityRepository&lt;Bar, Long&gt;, 
          PagingAndSortingRepository&lt;Bar, Long&gt; 
  {
      ...
  }
  </code></pre>
  
  <p>For the String example, I'm able to successfully query the findAll endpoint like so:</p>
  
  <pre><code>GET /api/data/foo/search/findAll?ids=eenie,meenie,miney,moe
  </code></pre>
  
  <p>But for the Long example, a similar query produces a 500 server error</p>
  
  <pre><code>GET /api/data/bar/search/findAll?ids=1035,1036,1042,2048
  
  {
    "timestamp": "2017-02-17T00:00:33.547Z",
    "status": 500,
    "error": "Internal Server Error",
    "exception": "org.springframework.dao.InvalidDataAccessApiUsageException",
    "message": "org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value element [1035] did not match expected type [java.lang.Long (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value element [1035] did not match expected type [java.lang.Long (n/a)]",
    "path": "/api/data/bar/search/findAll"
  }
  </code></pre>
  
  <p>The IllegalArgumentException is thrown in Hibernate JPA, at <code>org.hibernate.jpa.spi.BaseQueryImpl.validateCollectionValuedParameterBinding()</code>. When I put a breakpoint there, it's clear that the comma-separated string passed in as the "ids" query param is successfully parsed into a <code>List&lt;String&gt;</code> and then passed through the layers (spring-data-rest -> spring-data -> spring-data-jpa -> hibernate-jpa). The noted BaseQueryImpl method then iterates the String elements checking to see if they are instances of the expected Long type. They aren't, and thus, the IllegalArgugmentException.</p>
  
  <p>I've also tried the following: </p>
  
  <pre><code>GET /api/data/bar/search/findAll?ids=1035l,1036l,1042l,2048l
  </code></pre>
  
  <p>...but this gave the same error.</p>
  
  <p><strong>So here's the question</strong>: I really want a common, generics-enhanced method declaration in the IdentifiableEntityRepository interface so that I can reuse it across many repositories. Is there a way to make the parsing of the "ids" query parameter type-aware so that it works with non-String IDs?</p>