{"record":{"id":"3f050cfb7d197249","repo":"hibernate/hibernate-orm","slug":"failed-to-interpret-hql-syntax-ex-getmessage","errorCode":null,"errorMessage":"Failed to interpret HQL syntax [{ex.getMessage()}]","messagePattern":"Failed to interpret HQL syntax \\[(.+?)\\]","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java","lineNumber":128,"sourceCode":"\t\t\t// reset the input token stream and parser state\n\t\t\thqlParser.reset();\n\n\t\t\t// fall back to LL(k)-based parsing\n\t\t\thqlParser.getInterpreter().setPredictionMode( PredictionMode.LL );\n\t\t\thqlParser.setErrorHandler( new DefaultErrorStrategy() );\n\t\t\thqlParser.addErrorListener( new BaseErrorListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e1) {\n\t\t\t\t\tthrow new SyntaxException( prettifyAntlrError( offendingSymbol, line, charPositionInLine, msg, e1, hql, true ), hql );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn hqlParser.statement();\n\t\t}\n\t\tcatch ( ParsingException ex ) {\n\t\t\t// Note that this is supposed to represent a bug in the parser\n\t\t\t// We wrap and rethrow in order to attach the HQL query to the error\n\t\t\tthrow new QueryException( \"Failed to interpret HQL syntax [\" + ex.getMessage() + \"]\", hql, ex );\n\t\t}\n\t}\n\n\t/**\n\t * ANTLR's error messages are surprisingly bad,\n\t * so try to make them a bit better.\n\t */\n\tpublic static String prettifyAntlrError(\n\t\t\tObject offendingSymbol,\n\t\t\tint line, int charPositionInLine,\n\t\t\tString message,\n\t\t\tRecognitionException e,\n\t\t\tString hql,\n\t\t\tboolean includeLocation) {\n\t\tString errorText = \"\";\n\t\tif ( includeLocation ) {\n\t\t\terrorText += \"At \" + line + \":\" + charPositionInLine;\n\t\t\tif ( offendingSymbol instanceof CommonToken commonToken ) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java#L110-L146","documentation":"Error \"Failed to interpret HQL syntax [{ex.getMessage()}]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The HQL parser rejected the query text: Failed to interpret HQL syntax [<value>]","commonSituations":"Syntax errors in HQL/JPQL strings; the underlying parse exception message is interpolated.","solutions":["The legacy HQL translator failed to interpret the query syntax. Check the HQL for syntax errors near the reported location; consider using the standard (ANTLR) translator."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}