title: Is Select EXISTS() possible in JPQL?
body: <p>I'm trying to run a query that checks if some conditions are true and returns a simple boolean result as output.  What makes it slightly tricky is that one of the conditions is to test for whether no results are returned for a set of criteria.</p>
  
  <p>I'm currently using JPA-2.0 with hibernate as my provider, backed by MySQL.  I have gotten an example query working fine in MySQL, but when trying to get it running in JPQL it flops.  The MySQL query looks a bit like this:</p>
  
  <pre><code>Select exists(Select statement with criteria) 
    or not exists(Select statement with criteria);
  </code></pre>
  
  <p>I also got the same output using CASE, but as JPQL doesn't support that statement.</p>
  
  <p>Anyways, when I try to use a similar query in JPQL I get the error: </p>
  
  <blockquote>
    <p>"unexpected end of subtree"</p>
  </blockquote>
  
  <p>which from my understanding means that something is missing in the query. Does anyone have any idea how to fix it?</p>