title: JPQL Query with join and where clause subquery
body: <p>I am new to JPQL and am trying to write a join query that gets results from a subquery in the where clause. What I have lloks like this:</p>
  
  <pre><code>Query query = em.createQuery("SELECT distinct pt.srcCanum FROM Pmt pt " + 
              "LEFT OUTER JOIN pt.txnhistPK ps " +                     
              "WHERE  " +
              "pt.isudDt &gt; '2015-08-01' and pt.certdDt is null " + 
              "OR ps.pmtUid = "+
              "ALL(SELECT pq.pmtUid FROM txnhistPK pq" +
              "WHERE pq.pmtChngTs  &gt; '2015-08-01')");
  </code></pre>
  
  <p>But it doesn't work. I have tried many different ways and none work. Please help.</p>
  
  <p>Stack trace:
  javax.ejb.EJBException: See nested exception; nested exception is:  org.apache.openjpa.persistence.ArgumentException: "Encountered "ps . pmtUid exists" at character 131, but expected: ["(", "*", "+", "-", ".", "/", ":", "&lt;", "&lt;=", "&lt;>", "=", ">", ">=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH", "BY", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INNER", "IS", "JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE", "LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL", "OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", "SET", "SIZE", "SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM", "TYPE", "UPDATE", "UPPER", "WHERE", , , , , , , , ]." while parsing JPQL "SELECT distinct pt.srcCanum FROM Pmt pt LEFT OUTER JOIN pt.txnhistPK ps WHERE pt.isudDt > '2015-08-01' and pt.certdDt is null OR ps.pmtUid exists ALL(SELECT pq.pmtUid FROM txnhistPK pqWHERE pq.pmtChngTs > '2015-08-01')". See nested stack trace for original parse error. </p>
  
  <p>character 131 is the p in ps after the OR. The entities should not need to be posted to understand. First, they are huge. Here is a short rundown: pmt has a pmtUid and srcCanum. txnhist holds changes to pmt's and contains a composite key (txnhistPK) that contains pmtUid and pmtChngTs. I need the results from both tables when the criterion in the query are met.</p>