title: Persisting non-entity class that extends an entity (jpa) - example?
body: <p>The JPA tutorial states that one can have a non-entity that extends entity class:</p>
  
  <blockquote>
    <p>Entities may extend both entity and
    non-entity classes, and non-entity
    classes may extend entity classes. -  <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html" rel="nofollow noreferrer">http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html</a></p>
  </blockquote>
  
  <p>Is it possible to persist such structure? </p>
  
  <p>I want to do this:</p>
  
  <pre><code>@Entity
  abstract class Test { ... }
  
  class FirstConcreteTest extends Test { ... } // Non-ntity
  class SecondConcreteTest extends Test { ... } // Non-entity
  
  Test test = new FirstConcreteTest();
  
  em.persist(test);
  </code></pre>
  
  <p>What I would like it to do is to persist all fields mapped on abstract Test to a common database table for all concrete classes (first and second), leaving all fields of first and second test class unpersisted (these can contain stuff like EJBs, jdbc pools, etc).</p>
  
  <p>And a bonus question. Is it possible to persist abstract property too?</p>
  
  <pre><code>@Entity
  abstract class Test {
  
      @Column
      @Access(AccessType.PROPERTY)
      abstract public String getName();
  
  }
  
  class SecondConcreteTest extends Test {
      public String getName() {
          return "Second Concrete Test";
      }
  }
  </code></pre>