title: Getting sub-classes from EntityManager.find()
body: <p>I have a JPA entity that can be sub-classed, defined as follows:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy = InheritanceType.JOINED)
  @DiscriminatorColumn(name = "IDTYPE",
      discriminatorType = DiscriminatorType.STRING,
      length = 12)
  public class BaseObject implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      //etc
  </code></pre>
  
  <p>The benefit to this is that <strong>BaseObject</strong> and all its subclasses share the same ID field -- each value is unique to all of them.  My question is when I do an <strong>EntityManager.find()</strong> on the base class like this:</p>
  
  <pre><code>@PersistenceContext protected EntityManager em;
  
  //  find a record.
  
  BaseObject obj = em.find(BaseObject.class, longIDValue);
  </code></pre>
  
  <p>Will the <strong>find</strong> method return one of the sub-classes if it is using that particular ID?   Or will it always return just a <strong>BaseClass</strong> object?</p>
  
  <p>Follow-up question:  Is this behavior consistent among the different JPA implementations?  (e.g. Hibernate vs. EclipseLink)</p>