title: select distinct values using spring data rest
body: <p>I'm using java 8 and spring-data-rest to create API on my data.</p>
  
  <p>I have a table Car(id, name, date...)</p>
  
  <p>I'm trying to have an endpoint to retrieve distinct car names.</p>
  
  <p>here's my Repository : </p>
  
  <pre><code>@RepositoryRestResource(path = "cars")    
  public interface CarRepository extends JpaRepository&lt;Car, Long&gt; {
      //What i want to do
      //@Query(value = "select distinct c.name as name from Car c")
      @Query(value = "select distinct c from Car c")
      List&lt;Car&gt; findDistinctName();      
  }
  </code></pre>
  
  <p>The query commented does not work , i have an exception </p>
  
  <pre><code>java.lang.IllegalArgumentException: PersistentEntity must not be null! 
  </code></pre>
  
  <p>apparently this is the normal behavior of SDR.</p>
  
  <p>I tried another solution by using <code>Projections</code></p>
  
  <pre><code>@Projection(name = "name", types = {Car.class})
  public interface CarName {
      String getName();
  }
  </code></pre>
  
  <p>but i cant get the distinct values, any idea?</p>
  
  <p>Thank you :)</p>