hibernate/hibernate-orm · error · SemanticException

Could not resolve class '${className}' named for instantiati

Error message

Could not resolve class '${className}' named for instantiation

What it means

Error "Could not resolve class '${className}' named for instantiation" thrown in hibernate/hibernate-orm.

Source

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

	@Override
	public SqmDynamicInstantiation<?> visitInstantiationTarget(HqlParser.InstantiationTargetContext ctx) {
		if ( ctx.MAP() != null ) {
			return forMapInstantiation( mapJavaType, nodeBuilder() );
		}
		else if ( ctx.LIST() != null ) {
			return forListInstantiation( listJavaType, nodeBuilder() );
		}
		else {
			final var simplePath = ctx.simplePath();
			if ( simplePath == null ) {
				throw new SyntaxException( "Missing instantiation target type" );
			}
			final String className = instantiationClassName( simplePath );
			try {
				return forClassInstantiation( resolveInstantiationTargetType( className ), nodeBuilder() );
			}
			catch (ClassLoadingException e) {
				throw new SemanticException( "Could not resolve class '" + className + "' named for instantiation", query );
			}
		}
	}

	private String instantiationClassName(HqlParser.SimplePathContext ctx) {
		final String name = ctx.getText();
		return expectedResultTypeName != null && expectedResultTypeShortName.equals( name )
				? expectedResultTypeName
				: name;
	}

	private JavaType<?> resolveInstantiationTargetType(String className) {
		final String qualifiedName = creationContext.getJpaMetamodel().qualifyImportableName( className );
		final var targetJavaType = creationContext.classForName( qualifiedName );
		return creationContext.getTypeConfiguration().getJavaTypeRegistry().resolveDescriptor( targetJavaType );
	}

	@Override

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a fully-qualified class name that exists on the classpath in the instantiation.
  2. Check for typos in the class name.

When it happens

Trigger: A name referenced in a mapping, query, or configuration cannot be resolved at runtime.

Common situations: Typos in entity/attribute/mapping names, missing mappings, or refactoring without updating references.


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