hibernate/hibernate-orm · error · FunctionArgumentException

Argument '{}' of 'version()' is a '{}' and does not have a '

Error message

Argument '{}' of 'version()' is a '{}' and does not have a '@Version' attribute

What it means

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

Source

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

		}
	}

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

	@Override
	public SqmPath<?> visitEntityVersionReference(HqlParser.EntityVersionReferenceContext ctx) {
		return handleVersionPath( consumeDomainPath( ctx.path() ) );
	}

	@Nonnull
	private static <U> SqmPath<?> handleVersionPath(SqmPath<U> sqmPath) {
		if ( sqmPath.getReferencedPathSource().getPathType()
				instanceof AbstractIdentifiableType<U> identifiableType ) {
			if ( !identifiableType.hasVersionAttribute() ) {
				throw new FunctionArgumentException( "Argument '" + sqmPath.getNavigablePath()
							+ "' of 'version()' is a '" + identifiableType.getTypeName()
							+ "' and does not have a '@Version' attribute" );
			}
			final var versionAttribute = identifiableType.findVersionAttribute();
			assert versionAttribute != null; // Safe, we just checked hasVersionAttribute()
			return sqmPath.get( versionAttribute );
		}
		else {
			throw new FunctionArgumentException( "Argument '" + sqmPath.getNavigablePath()
						+ "' of 'version()' does not resolve to an entity type" );
		}
	}

	@Override
	public SqmPath<?> visitEntityNaturalIdExpression(HqlParser.EntityNaturalIdExpressionContext ctx) {
		return visitEntityNaturalIdReference( ctx.entityNaturalIdReference() );
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Pass an entity that declares a @Version attribute to version().
  2. Add a @Version property to the entity if optimistic locking is needed.

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/d0f564687bd7e246. Report an issue: GitHub.