title: Return custom object from Spring Data with Native Query
body: <p>My question is based on <a href="https://stackoverflow.com/questions/36328063/how-to-return-a-custom-object-from-a-spring-data-jpa-group-by-query#answer-36329166">another post</a>. How can I achieve the same with a native query? Native queries do not allow JPQL thus do not allow new instances either.</p>
  
  <p>My POJO.</p>
  
  <pre><code>class Coordinates {
  
      private final BigDecimal latitude
      private final BigDecimal longitude
  
      ...
  }
  </code></pre>
  
  <p>My database table contains coordinates for cities perimeter, so there are three columns: city_name, latitude, longitude. Each city contains lots (really, LOTS) of perimeter coordinates that will be used to build a shadow area in Google Maps.</p>
  
  <p>I intend to build a simple native query on that table that should return a list of coordinates. </p>