title: How to map a native query to POJO class using jpa and hibernate
body: <p>I am using both JPA and hibernate in my project.</p>
  
  <p>I have created a query in which i made join operation on many tables. So I created a native one. The results that i get are in a list of object[] but i would like <strong>the results to be converted automatically to a java POJO class</strong>.
  You can check both the query syntax and POJO java class below.</p>
  
  <p><strong>JPA Query</strong></p>
  
  <pre><code>@Query(value = "SELECT obsp.Identifier, obs.phenomenontimestart, nv.value " +
          "From Series s " +
          "INNER JOIN Featureofinterest fi on s.featureofinterestid = fi.featureofinterestid " +
          "INNER JOIN ObservableProperty obsp on s.observablepropertyid = obsp.ObservablePropertyId " +
          "INNER JOIN Observation obs on s.seriesid = obs.seriesid " +
          "INNER JOIN NumericValue nv on nv.observationid = obs.observationid " +
          "where fi.identifier = ?1 and obs.phenomenontimestart &gt;= ?2 AND obs.phenomenontimestart &lt;= ?3 " +
          "order by obs.phenomenontimestart",
          nativeQuery = true)
  List&lt;CurrentMeasure&gt; findCurrentMeasure(String ident, Timestamp t1, Timestamp t2);
  </code></pre>
  
  <p><strong>POJO class</strong></p>
  
  <pre><code>public class CurrentMeasure {
  
  private String identifier;
  private Timestamp dateTime;
  private BigDecimal bigDecimal;
  
  public CurrentMeasure() {
  }
  
  public CurrentMeasure(String identifier, Timestamp dateTime, BigDecimal bigDecimal) {
      this.identifier = identifier;
      this.dateTime = dateTime;
      this.bigDecimal = bigDecimal;
  }
  
  public String getIdentifier() {
      return identifier;
  }
  
  public void setIdentifier(String identifier) {
      this.identifier = identifier;
  }
  
  public Timestamp getDateTime() {
      return dateTime;
  }
  
  public void setDateTime(Timestamp dateTime) {
      this.dateTime = dateTime;
  }
  
  public BigDecimal getBigDecimal() {
      return bigDecimal;
  }
  
  public void setBigDecimal(BigDecimal bigDecimal) {
      this.bigDecimal = bigDecimal;
  }
  </code></pre>
  
  <p>}</p>