HQL parsing does not detect abnormal parenthesis, but silently ignores the order by clause instead. Issue detected on 5.0.2, reproductible on 5.2.6
SELECT f FROM Foo f ) ORDER BY f.bar
maven test case provided, thanks for your help