hibernate/hibernate-orm · error · QueryException

Failed to interpret HQL syntax [{ex.getMessage()}]

Error message

Failed to interpret HQL syntax [{ex.getMessage()}]

What it means

Error "Failed to interpret HQL syntax [{ex.getMessage()}]" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java:128

			// reset the input token stream and parser state
			hqlParser.reset();

			// fall back to LL(k)-based parsing
			hqlParser.getInterpreter().setPredictionMode( PredictionMode.LL );
			hqlParser.setErrorHandler( new DefaultErrorStrategy() );
			hqlParser.addErrorListener( new BaseErrorListener() {
				@Override
				public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e1) {
					throw new SyntaxException( prettifyAntlrError( offendingSymbol, line, charPositionInLine, msg, e1, hql, true ), hql );
				}
			} );

			return hqlParser.statement();
		}
		catch ( ParsingException ex ) {
			// Note that this is supposed to represent a bug in the parser
			// We wrap and rethrow in order to attach the HQL query to the error
			throw new QueryException( "Failed to interpret HQL syntax [" + ex.getMessage() + "]", hql, ex );
		}
	}

	/**
	 * ANTLR's error messages are surprisingly bad,
	 * so try to make them a bit better.
	 */
	public static String prettifyAntlrError(
			Object offendingSymbol,
			int line, int charPositionInLine,
			String message,
			RecognitionException e,
			String hql,
			boolean includeLocation) {
		String errorText = "";
		if ( includeLocation ) {
			errorText += "At " + line + ":" + charPositionInLine;
			if ( offendingSymbol instanceof CommonToken commonToken ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. 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.

When it happens

Trigger: The HQL parser rejected the query text: Failed to interpret HQL syntax [<value>]

Common situations: Syntax errors in HQL/JPQL strings; the underlying parse exception message is interpolated.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/3f050cfb7d197249. Report an issue: GitHub.