title: Hibernate: Fetch all records from a single table, regardless of type defined with @DiscriminatorValue
body: <p>Hibernate has powerful mechanism to make several entities to share same table in the database. For me, being able to fetch all records regardless of the subtypes would be the most important thing. However this doesn't seem to work. </p>
  
  <p>Provided we have some standard setup:</p>
  
  <pre><code>@Entity
  @Table(name = "plane")
  @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
  @DiscriminatorColumn(
      name="planetype",
      discriminatorType=DiscriminatorType.STRING
  )
  public abstract class Plane { ... }
  
  @Entity
  @Table(name = "plane")
  @DiscriminatorValue("A320")
  public class A320 extends Plane { ... }       
  
  @Entity
  @Table(name = "plane")
  @DiscriminatorValue("B777")
  public class B777 extends Plane { ... }       
  </code></pre>
  
  <p>What do I need to access all the planes we have on the table?</p>
  
  <pre><code>@Entity
  @DiscriminatorValue("")
  public class AnyPlane extends Plane { ... } // this doesn't work      
  
  @Entity    
  public class AnyPlane extends Plane { ... } // this doesn't work either
  </code></pre>
  
  <p>I try to fetch <code>AnyPlane</code>s same way I usually do...</p>
  
  <pre><code>CriteriaBuilder cb = getSession().getCriteriaBuilder();
  CriteriaQuery&lt;AnyPlane&gt; q = cb.createQuery(AnyPlane.class);
  Root&lt;AnyPlane&gt; root = q.from(AnyPlane.class);
  
  Query&lt;AnyPlane&gt; query = getSession().createQuery(q.select(root)
      .where(someRestrictions)        
  );
  return query.list();
  </code></pre>
  
  <p>...and get empty list, because Hibernate considers even empty string to be a valid denominator. What would I do? </p>
  
  <p>Worth to mention, that the planes already happyly fly up the code stack, and my goal is to refactor the DB layer without introducing much changes. I'm also not keen to use native SQL.</p>