title: Subclass discrimination (TYPE) using a class member in JPA/JPQL
body: <p>I want to discriminate by type in a query, but what I want to discriminate is not the entity in the SELECT clause, but a member of it.</p>
  
  <p>For example, instead of using TYPE like this:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT p
  FROM Project p
  WHERE TYPE(p) = DesignProject OR TYPE(p) = QualityProject
  </code></pre>
  
  <p>I need to use it like this:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT p
  FROM Project p
  WHERE TYPE(p.leader) = Architect OR TYPE(p.leader) = Engineer
  </code></pre>
  
  <p><code>Architect</code> and <code>Engineer</code> are subclasses of <code>Leader</code> class.</p>
  
  <p>I have already tried that, but I am getting this error:</p>
  
  <p><code>org.hibernate.QueryException: could not resolve property</code></p>