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'