title: Spring Boot + MongoRepository, get all rows but only certain fields
body: <p>I'm trying to fetch all the entries in my database, but only the <code>reference</code> fields. In my <code>MongoRepository</code>, I want to use a custom query, so it doesn't use the method name to build up the query. The following doesn't seem to work:</p>
  
  <pre><code>public interface JvRepository extends MongoRepository&lt;Jv, String&gt; {
      @Query(value = "{}", fields = "{ id : 0, reference : 1 }")
      public List&lt;String&gt; findAllJvReferences();
  }
  
  public class Jv {
      @Id
      private String id;
  
      private String reference;
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Jv cannot be cast to <code>java.lang.String</code></p>
  </blockquote>
  
  <p>I tell it to not get the <code>id</code>, and do get the <code>reference</code> right? Why does it not return a <code>String</code>, but still a <code>Jv</code>?</p>
  
  <p>I guess I should pass something in the value that tells Mongo to select everything, but I have no idea what. Or is there something else wrong with this code?</p>