hibernate/hibernate-orm · error · ParsingException
Unexpected terminal node [{text}]
Error message
Unexpected terminal node [{text}] What it means
Error "Unexpected terminal node [{text}]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:4033
@Override
public SqmExpression<?> visitLiteralExpression(HqlParser.LiteralExpressionContext ctx) {
return (SqmExpression<?>) ctx.getChild( 0 ).accept( this );
}
@Override
public SqmExpression<?> visitUnaryNumericLiteralExpression(HqlParser.UnaryNumericLiteralExpressionContext ctx) {
final var node = (TerminalNode) ctx.getChild( 1 ).getChild( 0 );
final var symbol = ((TerminalNode) ctx.getChild( 0 ).getChild( 0 )).getSymbol();
final String text = symbol.getType() == HqlParser.MINUS ? "-" + node.getText() : node.getText();
return switch ( node.getSymbol().getType() ) {
case HqlParser.INTEGER_LITERAL -> integerLiteral( text );
case HqlParser.LONG_LITERAL -> longLiteral( text );
case HqlParser.BIG_INTEGER_LITERAL -> bigIntegerLiteral( text );
case HqlParser.HEX_LITERAL -> hexLiteral( text );
case HqlParser.FLOAT_LITERAL -> floatLiteral( text );
case HqlParser.DOUBLE_LITERAL -> doubleLiteral( text );
case HqlParser.BIG_DECIMAL_LITERAL -> bigDecimalLiteral( text );
default -> throw new ParsingException( "Unexpected terminal node [" + text + "]" );
};
}
@Override
public Object visitBinaryLiteral(HqlParser.BinaryLiteralContext ctx) {
final var firstNode = (TerminalNode) ctx.getChild( 0 );
if ( firstNode.getSymbol().getType() == HqlParser.BINARY_LITERAL ) {
return binaryLiteral( firstNode.getText() );
}
else {
final var text = new StringBuilder( "x'" );
final int size = ctx.getChildCount();
for ( int i = 0; i < size; i++ ) {
final var hex = (TerminalNode) ctx.getChild( i );
if ( hex.getSymbol().getType() == HqlParser.HEX_LITERAL ) {
final String hexText = hex.getText();
if ( hexText.length() != 4 ) {
throw new LiteralNumberFormatException( "not a byte: " + hexText );View on GitHub (pinned to fad1729dce)
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.
When it happens
Trigger: The HQL parser produced a node the translator does not expect: Unexpected terminal node [<value>]
Common situations: Usually an internal grammar edge case in window-frame or expression parsing; can surface with unusual but syntactically accepted HQL.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/7bae095916f04542.
Report an issue: GitHub.