The query compiler does not check all the rules as defined in the Java Persistence Language chapter of the specification. In particular, it does not check:
Type compatibility of function arguments.
Type compatibility of operands of arithmetic, logical, and comparison operators
SELECT clause requirements for an ORDER BY query.
An invalid query may compile but may cause a SQLException at runtime. Or it might happen that the underlying database is less restrictive and supports the generated SQL, but executing the same query on a different database fails with a SQLException.
Verify the above conditions manually.