title: JPA Native Query for Entity with Inheritance
body: <p>I have an entity class and a subclass based on that entity:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
  public class A
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  public class B extends A
  </code></pre>
  
  <p>I need to issue a native query that uses a stored procedure on the base class (A) only.  If I attempt it as follows:</p>
  
  <pre><code>entityManager.createNativeQuery("select * from A a where procedure(f)",A.class).getResultList()
  </code></pre>
  
  <p>I get an error regarding "The column clazz_ was not found in the ResultSet".  I assume that the JPA provider adds this column in order to discriminate between the base class and the extended class.  I can work around this problem by explicitly adding the clazz column and all of the fields from the subclass:</p>
  
  <pre><code>entityManager.createNativeQuery("select *,1 as clazz_,null as prop1,null as prop2 from A a where procedure(f)",A.class).getResultList()
  </code></pre>
  
  <p>where "prop1" and "prop2" are properties of the subclass B.  However, this seems like an unnecessary hack and is prone to maintenance problems if the subclass B changes.  </p>
  
  <p>My question is: How can I query using a stored procedure on an entity that has inheritance defined on it?</p>