hibernate/hibernate-orm · error · HqlInterpretationException

Cannot dereference an embeddable name

Error message

Cannot dereference an embeddable name

What it means

SqmLiteralEmbeddableType is the SQM node Hibernate creates when a path segment resolves to an embeddable class name (a fully-qualified type name used as a literal). An embeddable name has no members to navigate, so resolvePathPart throws HqlInterpretationException('Cannot dereference an embeddable name') at query interpretation time.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/expression/SqmLiteralEmbeddableType.java:78

	public void internalApplyInferableType(@Nullable SqmBindableType<?> type) {
	}

	@Override
	public <X> X accept(SemanticQueryWalker<X> walker) {
		return walker.visitEmbeddableTypeLiteralExpression( this );
	}

	@Override
	public String asLoggableText() {
		return "TYPE(" + embeddableDomainType + ")";
	}

	@Override
	public SemanticPathPart resolvePathPart(
			String name,
			boolean isTerminal,
			SqmCreationState creationState) {
		throw new HqlInterpretationException( "Cannot dereference an embeddable name" );
	}

	@Override
	public SqmPath<?> resolveIndexedAccess(
			SqmExpression<?> selector,
			boolean isTerminal,
			SqmCreationState creationState) {
		throw new HqlInterpretationException( "Cannot dereference an embeddable name" );
	}

	@Override
	public void appendHqlString(StringBuilder hql, SqmRenderContext context) {
		hql.append( embeddableDomainType.getTypeName() );
	}

	@Override
	public boolean equals(@Nullable Object object) {
		return object instanceof SqmLiteralEmbeddableType<?> that

View on GitHub (pinned to fad1729dce)

Solutions

  1. Navigate from an alias/root that holds an embeddable-valued attribute: select o.address.city from Order o.
  2. If comparing types, compare type(...) results instead of dereferencing the name.
  3. Fix the alias/typo so every path starts at an identification variable.

Example fix

-- before
select com.acme.Address.city from Order o   -- embeddable name dereferenced

-- after
select o.address.city from Order o           -- navigate via the embeddable attribute
Defensive patterns

Strategy: try-catch

Try / catch

try {
    return session.createQuery( hql, Tuple.class ).getResultList();
} catch ( org.hibernate.query.hql.HqlInterpretationException e ) {
    // an embeddable name was dereferenced - fix the path/alias
    throw new BadRequestException( "Cannot dereference embeddable name in query: " + e.getMessage(), e );
}

Prevention

When it happens

Trigger: HQL that continues a path after an embeddable class name: select com.acme.Address.city from ..., where com.acme.Address.zip = ..., or criteria code calling resolvePathPart on an SqmLiteralEmbeddableType node.

Common situations: Confusing the embeddable's class name with an entity alias or identification variable; missing or typo'd aliases so Hibernate re-interprets a token as a type name; Java-style static access to embeddable fields copied into HQL.

Related errors


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