hibernate/hibernate-orm · error · IllegalArgumentException

Unexpected frame exclusion

Error message

Unexpected frame exclusion: {lastChild}

What it means

Thrown while parsing a window frame clause: the trailing frame-exclusion keyword matched none of the recognized exclusions (current row, group, ties, no others). An internal switch default echoing the last child of the frame clause, reached only when the grammar yields an unexpected exclusion token.

Solutions

  1. The window frame exclusion is invalid. Use CURRENT ROW, GROUP, TIES, or NO OTHERS in the frame exclusion.
Defensive patterns

Strategy: validation

When it happens

Trigger: The HQL parser produced a node the translator does not expect: Unexpected frame exclusion: <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/ce21bbc0f0b7cd7e. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:5403

			else {
				frameStartIndex = 1;
				endKind = FrameKind.CURRENT_ROW;
				endExpression = null;
			}
			startKind = getFrameKind( frameClause.getChild( frameStartIndex ) );
			startExpression =
					startKind == FrameKind.OFFSET_FOLLOWING || startKind == FrameKind.OFFSET_PRECEDING
							? (SqmExpression<?>) frameClause.getChild( frameStartIndex ).getChild( 0 ).accept( this )
							: null;
			final var lastChild = frameClause.getChild( frameClause.getChildCount() - 1 );
			if ( lastChild instanceof HqlParser.FrameExclusionContext ) {
				final var token = ((TerminalNode) lastChild.getChild( 1 )).getSymbol();
				exclusion = switch ( token.getType() ) {
					case HqlParser.CURRENT -> FrameExclusion.CURRENT_ROW;
					case HqlParser.GROUP -> FrameExclusion.GROUP;
					case HqlParser.TIES -> FrameExclusion.TIES;
					case HqlParser.NO -> FrameExclusion.NO_OTHERS;
					default -> throw new IllegalArgumentException( "Unexpected frame exclusion: " + lastChild );
				};
			}
			else {
				exclusion = FrameExclusion.NO_OTHERS;
			}
		}
		else {
			mode = FrameMode.RANGE;
			startKind = FrameKind.UNBOUNDED_PRECEDING;
			startExpression = null;
			endKind = FrameKind.CURRENT_ROW;
			endExpression = null;
			exclusion = FrameExclusion.NO_OTHERS;
		}
		return new SqmOver<>(
				function,
				partitions,
				orderList,

View on GitHub (pinned to fad1729dce)