title: JPA Native Query (SQL View)
body: <p>I have two Entities <code>Customer</code> and <code>Account</code>.</p>
  
  <pre><code>@Entity
  @Table(name="customer")
  public class Customer
  {
      private Long id;
      private String name;
      private Long accountId;
      private String accountType;
      private String accountName;
  
      ...
  }
  
  @Entity
  @Table(name="account")
  public class Account
  {
      private Long id;
      private String accountName;
      private String accountType;
      ...
  }
  </code></pre>
  
  <p>I have an SQL query:  </p>
  
  <pre><code>select 
      a.id as account_id, 
      a.account_name, 
      a.account_type, 
      d.id, 
      d.name
  from account a, 
       customer d`
  where d.account_id = a.id
  </code></pre>
  
  <p><strong>Assumption</strong></p>
  
  <ol>
  <li><code>account</code> and <code>customer</code> tables are created in the database during application startup.</li>
  <li><code>accountType</code> and <code>accountName</code> fields of Customer entity should not be created in the database. That is, only <code>id</code> and <code>name</code> columns will be created in the customer database table.</li>
  </ol>
  
  <p><strong>Question</strong></p>
  
  <p>How do I run the above SQL query and return a <code>Customer</code> Entity with the <code>accountType</code> and <code>accountName</code> properties populated with the SQL query's account_name and account_type values.</p>