{"record":{"id":"7bae095916f04542","repo":"hibernate/hibernate-orm","slug":"unexpected-terminal-node-text","errorCode":null,"errorMessage":"Unexpected terminal node [{text}]","messagePattern":"Unexpected terminal node \\[(.+?)\\]","errorType":"exception","errorClass":"ParsingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":4033,"sourceCode":"\t@Override\n\tpublic SqmExpression<?> visitLiteralExpression(HqlParser.LiteralExpressionContext ctx) {\n\t\treturn (SqmExpression<?>) ctx.getChild( 0 ).accept( this );\n\t}\n\n\t@Override\n\tpublic SqmExpression<?> visitUnaryNumericLiteralExpression(HqlParser.UnaryNumericLiteralExpressionContext ctx) {\n\t\tfinal var node = (TerminalNode) ctx.getChild( 1 ).getChild( 0 );\n\t\tfinal var symbol = ((TerminalNode) ctx.getChild( 0 ).getChild( 0 )).getSymbol();\n\t\tfinal String text = symbol.getType() == HqlParser.MINUS ? \"-\" + node.getText() : node.getText();\n\t\treturn switch ( node.getSymbol().getType() ) {\n\t\t\tcase HqlParser.INTEGER_LITERAL -> integerLiteral( text );\n\t\t\tcase HqlParser.LONG_LITERAL -> longLiteral( text );\n\t\t\tcase HqlParser.BIG_INTEGER_LITERAL -> bigIntegerLiteral( text );\n\t\t\tcase HqlParser.HEX_LITERAL -> hexLiteral( text );\n\t\t\tcase HqlParser.FLOAT_LITERAL -> floatLiteral( text );\n\t\t\tcase HqlParser.DOUBLE_LITERAL -> doubleLiteral( text );\n\t\t\tcase HqlParser.BIG_DECIMAL_LITERAL -> bigDecimalLiteral( text );\n\t\t\tdefault -> throw new ParsingException( \"Unexpected terminal node [\" + text + \"]\" );\n\t\t};\n\t}\n\n\t@Override\n\tpublic Object visitBinaryLiteral(HqlParser.BinaryLiteralContext ctx) {\n\t\tfinal var firstNode = (TerminalNode) ctx.getChild( 0 );\n\t\tif ( firstNode.getSymbol().getType() == HqlParser.BINARY_LITERAL ) {\n\t\t\treturn binaryLiteral( firstNode.getText() );\n\t\t}\n\t\telse {\n\t\t\tfinal var text = new StringBuilder( \"x'\" );\n\t\t\tfinal int size = ctx.getChildCount();\n\t\t\tfor ( int i = 0; i < size; i++ ) {\n\t\t\t\tfinal var hex = (TerminalNode) ctx.getChild( i );\n\t\t\t\tif ( hex.getSymbol().getType() == HqlParser.HEX_LITERAL ) {\n\t\t\t\t\tfinal String hexText = hex.getText();\n\t\t\t\t\tif ( hexText.length() != 4 ) {\n\t\t\t\t\t\tthrow new LiteralNumberFormatException( \"not a byte: \" + hexText );","sourceCodeStart":4015,"sourceCodeEnd":4051,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L4015-L4051","documentation":"Error \"Unexpected terminal node [{text}]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The HQL parser produced a node the translator does not expect: Unexpected terminal node [<value>]","commonSituations":"Usually an internal grammar edge case in window-frame or expression parsing; can surface with unusual but syntactically accepted HQL.","solutions":["The HQL grammar produced a terminal node the translator does not handle; this indicates a syntax error near the reported token. Inspect the query text around the token and fix the syntax."],"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"}