Spring data jpa, jparepository returning list of string in place of DTO object
<p>I have a <code>interface</code> implementing <strong><code>JPARepository</code></strong> and have three methods, one of them is having a custom <code>@Query</code>.</p>

<pre><code>public interface PersonRepository extends JpaRepository&lt;Person, Long&gt; {

  List&lt;Person&gt; getPersonBycountryCode(String countryCode);

  List&lt;Person&gt; findByCountryCodeAndCity(String string,String city);

  @Query(value = "SELECT person.firstName as firstName, person.lastName as lastName, person.countryCode as country, person.city as city,"
              + " SQRT(POWER((69.1 * (person.age - :age )) , 2 )"
              + " + POWER((53 * (person.experience - :experience )), 2)) as eligibility"
              + " FROM Person person"
              + " ORDER BY eligibility ASC")
  List&lt;PersonDetailsDto&gt; findPersonDetailsByEligibility(
          @Param("age") BigDecimal age,
          @Param("experience") BigDecimal experience,
          Pageable pageable
  );
}
</code></pre>

<p><strong>Problem is:</strong> method with <code>@Query</code> does not return list of <code>PersonDetailsDto</code> but return list of list of strings (<strong><code>List&lt;List&lt;String&gt;&gt;</code></strong>). </p>

<p><code>PersonDetailsDto</code> is a POJO class with all the variables described in a query output <strong>(firstName, lastName, country, city, eligibility)</strong> and also a constructor with all the variables as Parameters. Other two methods does return list of Person object.</p>

<p>Any idea?</p>