title: Returning a single projection from native query
body: <p>I am trying to return a projection, not a list of projections, from a native query. I keep running into a converter error:</p>
  
  <pre><code>org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [PersonRepository$NameProjection]
  </code></pre>
  
  <p>My spring version is fairly old (spring-boot-starter-data-jpa v1.5.3), but I can't upgrade it for external reasons. So I was just wondering if I could make it work with the version I have.</p>
  
  <p>My repository looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>public PersonRepository extends JpaRepository&lt;Person, Integer&gt; {
  
      interface NameProjection {
          private String firstName;
          private String lastName;
      }
  
      @Query(value = "SELECT first_name AS firstName, last_name AS lastName FROM person where person_id = :personId", nativeQuery = true)
      NameProjection getPersonNameById(@Param("personId") Integer personId);
  
      @Query(value = "SELECT first_name AS firstName, last_name AS lastName FROM person", nativeQuery = true)
      List&lt;NameProjection&gt; getPersonNames();
  }
  </code></pre>
  
  <p>When I call <code>getPersonNameById()</code>, I get the error above. What's interesting is that method works if I change my projection to have only 1 field, let's say <code>firstName</code>. However, whenever there is more than one field, I get the converter error above.</p>
  
  <p>Calling <code>getPersonNames()</code> works exactly like I expect where a list of the projections are returned with the fields I specified.</p>
  
  <p>How can I change my repository code so that Spring will allow me to return a single projection?</p>
  
  <p>Thank you in advance.</p>