hibernate/hibernate-orm · error · HqlInterpretationException

path did not map to a column

Error message

path did not map to a column

What it means

HQL's column("name", path) function renders a raw qualified column reference. The path argument must be an Assignable with column references or an Expression exposing a ColumnReference; if the argument is a literal, a parameter, or an expression with no column backing (formula, aggregate, computed value), interpretation fails with HqlInterpretationException.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/function/SqlColumn.java:54

		this.columnName = columnName;
	}

	@Override
	public void render(
			SqlAppender sqlAppender,
			List<? extends SqlAstNode> arguments,
			ReturnableType<?> returnType,
			SqlAstTranslator<?> walker) {
		final SqlAstNode sqlAstNode = arguments.get(0);
		final ColumnReference reference;
		if ( sqlAstNode instanceof Assignable assignable ) {
			reference = assignable.getColumnReferences().get(0);
		}
		else if ( sqlAstNode instanceof Expression expression ) {
			reference = expression.getColumnReference();
		}
		else {
			throw new HqlInterpretationException( "path did not map to a column" );
		}
		sqlAppender.appendSql( reference.getQualifier() );
		sqlAppender.appendSql( '.' );
		sqlAppender.appendSql( columnName );
	}

}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass a column-backed entity attribute path: column("x", e.someAttribute)
  2. Use sql("...?") with placeholders for arbitrary literal SQL fragments
  3. Verify the referenced attribute is a normal column mapping, not a @Formula or derived expression
  4. Check that the path resolves to an entity alias actually present in the query

Example fix

// before
select column('aud_id', :auditRef) from AuditLog a

// after
select column('aud_id', a.sourceRef) from AuditLog a
Defensive patterns

Strategy: validation

Validate before calling

// column("name", path) requires a plain alias.attribute path — reject params/literals early
private static final java.util.regex.Pattern COLUMN_ARG =
    java.util.regex.Pattern.compile("column\\(\\s*\"[^\"]*\"\\s*,\\s*([A-Za-z_][\\w]*\\.[A-Za-z_][\\w.]*)\\s*\\)");

static boolean columnArgsArePaths(String hql) {
    java.util.regex.Matcher m = COLUMN_ARG.matcher(hql);
    while (m.find()) { /* matched a well-formed path */ }
    return !hql.toLowerCase(java.util.Locale.ROOT).matches("(?s).*column\\(\\s*\"[^\"]*\"\\s*,\\s*[:'\\d].*");
}

Try / catch

try {
    return em.createQuery(hql).getResultList();
} catch (org.hibernate.query.HqlInterpretationException e) {
    if (e.getMessage() != null && e.getMessage().contains("did not map to a column")) {
        throw new QuerySetupException("column() needs a column-backed attribute path, not a literal/parameter", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: HQL: column("x", :param), column("x", 'literal'), or a path that resolves to a formula/aggregate instead of a column-backed attribute.

Common situations: Hand-written HQL fragments in @Where/@SQL restrictions; migrating native SQL fragments to HQL by replacing table aliases with column() calls; referencing keys of element collections in odd positions.

Related errors


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