title: How to search on subclass attribute with a JPA CriteriaQuery?
body: <p>I am trying to write a query to search a subclass attribute that is not in its superclass and return all objects of the superclass.  Currently I am getting a NullPointerException when I try and do person.get("specialAttribute").</p>
  
  <pre><code>@Inheritance(strategy = InheritanceType.JOINED)
  @Entity
  public abstract class Person {
      public String searchableAttribute;
  }
  
  @Entity
  @Table( name = "normal_person" )
  public class NormalPerson extends Person {
  
  }
  
  @Entity
  @Table( name = "special_person" )
  public class SpecialPerson extends Person {
      @Column(nullable = false, unique = true)
      public String specialAttribute;
  }
  
  // Controller method
  
      Root&lt;Person&gt; person = query.from(Person.class);
      query.where(
              builder.or(
                      builder.like(person.&lt;String&gt;get("specialAttribute"), "foo"),
                      builder.like(person.&lt;String&gt;get("searchableAttribute"), "foo")
              )
      );
  </code></pre>