hibernate/hibernate-orm · error · FunctionArgumentException

Argument '{}' of 'id()' is a '{}' and does not have a well-d

Error message

Argument '{}' of 'id()' is a '{}' and does not have a well-defined '@Id' attribute

What it means

Error "Argument '{}' of 'id()' is a '{}' and does not have a well-defined '@Id' attribute" thrown in hibernate/hibernate-orm.

Source

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

	@Override
	public SqmExpression<?> visitEntityIdExpression(HqlParser.EntityIdExpressionContext ctx) {
		return visitEntityIdReference( ctx.entityIdReference() );
	}

	@Override
	public SqmPath<?> visitEntityIdReference(HqlParser.EntityIdReferenceContext ctx) {
		if ( ctx.pathContinuation() != null ) {
			throw new UnsupportedOperationException( "Path continuation from 'id()' reference not yet implemented" );
		}

		final var sqmPath = consumeDomainPath( ctx.path() );
		if ( sqmPath.getReferencedPathSource().getPathType()
				instanceof IdentifiableDomainType<?> identifiableType ) {
			final var identifierDescriptor = identifiableType.getIdentifierDescriptor();
			if ( identifierDescriptor == null ) {
				// mainly for benefit of Hibernate Processor
				throw new FunctionArgumentException( "Argument '" + sqmPath.getNavigablePath()
						+ "' of 'id()' is a '" + identifiableType.getTypeName()
						+ "' and does not have a well-defined '@Id' attribute" );
			}
			return sqmPath.get( identifierDescriptor.getPathName(), true );
		}
		else if ( sqmPath instanceof SqmAnyValuedSimplePath<?> ) {
			return sqmPath.resolvePathPart( AnyKeyPart.KEY_NAME, true,
					processingStateStack.getCurrent().getCreationState() );
		}
		else {
			throw new FunctionArgumentException( "Argument '" + sqmPath.getNavigablePath()
					+ "' of 'id()' does not resolve to an entity type" );
		}
	}

	@Override
	public SqmExpression<?> visitEntityVersionExpression(HqlParser.EntityVersionExpressionContext ctx) {
		return visitEntityVersionReference( ctx.entityVersionReference() );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass an entity with a well-defined single @Id attribute to id().
  2. Use the explicit id path (e.g. e.id) instead of the id() function.

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


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