Executing a query like the below
Looks like something changed between Hibernate 4.2.7.SP5-redhat-1 (EAP 6.2.4) and Hibernate 4.2.14.SP1-redhat-1 (EAP 6.3.0) with regard to antlr parsing so that the keyword 'NULL' causes a parse failure in the HQL query. The issue remains in 5.0.9 and 5.1.0
Replacing the 'CAST(NULL as long)' with 'CAST(12 as long)' works ...
If the query in question is a @NamedQuery the failure will be at the point the entity manager is created. The same issue can be seen with a simple dynamic HQL query, however, as the testcase attached shows. The test uses an H2 db and can be run using 'mvn clean test'
A workaround is to replace null literals with nullif( 1, 1 ).
In 4.2 branch, `git bisect` shows that it was broken by commit cfc0327637d80932782858705dd180010160dde5
In master branch, `git bisect` shows that it was broken by commit cbc79c2d61fc8c0d64dae90c61fe98990635c051 (in 4.3.6).
Fixed in master, 5.1, and 5.0 branches.