title: Hibernate Criteria query on properties of subclasses
body: <p>Suppose I have:</p>
  
  <pre><code>abstract class Shape { boolean visible; }
  
  class Circle extends Shape { int radius; }
  
  class Square extends Shape { int side; }
  </code></pre>
  
  <p>Suppose I want all Shapes with <code>visible=true</code>, plus all Circles with <code>radius=10</code>, plus all Squares with <code>side=15</code>.</p>
  
  <p>I can't do this:</p>
  
  <pre><code>List results = session.createCriteria(A.class)
      .add(Restrictions.disjunction()
         .add(Restrictions.eq("visible", true))
         .add(Restrictions.eq("radius", 10))
         .add(Restrictions.eq("side", 15))).list();
  </code></pre>
  
  <p>Because <code>radius</code> and <code>side</code> are not <code>Shape</code> fields:</p>
  
  <pre><code>Caused by: org.hibernate.QueryException: could not resolve property: radius of: Shape
  </code></pre>
  
  <p><strong>My question is:</strong> How can I solve this, in a single query, preferably without using HQL?</p>
  
  <p><strong>Also:</strong> Would Shape's <code>InheritanceType</code> (<code>TABLE_PER_CLASS</code>, <code>JOINED</code>, or <code>SINGLE_TABLE</code>) make any difference to this problem?</p>