title: JPQL: "where" clause on "case" variable
body: <p>The following JPQL query runs without issues:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT t, CASE WHEN (e.language.language = 'en' AND e.language.country = 'GB' AND e.language.variant = '') THEN e.text ELSE '' END sortProperty FROM Glossary g JOIN g.terms t JOIN t.expressions e ORDER BY sortProperty
  </code></pre>
  
  <p>whereas the following fails:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT t, CASE WHEN (e.language.language = 'en' AND e.language.country = 'GB' AND e.language.variant = '') THEN e.text ELSE '' END sortProperty FROM Glossary g JOIN g.terms t JOIN t.expressions e WHERE sortProperty = 'asdf' ORDER BY sortProperty
  </code></pre>
  
  <p>With this exception:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Invalid unbound variable "sortproperty" in query.
  </code></pre>
  
  <p>Is this a limitation in the query syntax and can this somehow be circumvented (perhaps using the Criteria API)?</p>
  
  <p>Thanks and best regards,
  Pascal</p>