hibernate/hibernate-orm · error · IllegalArgumentException

Could not locate entity mapping : {}

Error message

Could not locate entity mapping : {}

What it means

Error "Could not locate entity mapping : {}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/results/internal/Builders.java:162

		return new DynamicResultBuilderInstantiation<>( targetJtd );
	}

	public static ResultBuilder attributeResult(
			String columnAlias,
			String entityName,
			String attributePath,
			SessionFactoryImplementor sessionFactory) {
		if ( attributePath.contains( "." ) ) {
			throw new UnsupportedOperationException(
					"Support for defining a NativeQuery attribute result based on a composite path is not yet implemented"
			);
		}

		final MappingMetamodelImplementor mappingMetamodel = sessionFactory.getMappingMetamodel();
		final String fullEntityName = mappingMetamodel.getImportedName( entityName );
		final EntityPersister entityMapping = mappingMetamodel.findEntityDescriptor( fullEntityName );
		if ( entityMapping == null ) {
			throw new IllegalArgumentException( "Could not locate entity mapping : " + fullEntityName );
		}

		final AttributeMapping attributeMapping = entityMapping.findAttributeMapping( attributePath );
		if ( attributeMapping == null ) {
			throw new IllegalArgumentException( "Could not locate attribute mapping : " + fullEntityName + "." + attributePath );
		}

		if ( attributeMapping instanceof SingularAttributeMapping singularAttributeMapping ) {
			return new DynamicResultBuilderAttribute( singularAttributeMapping, columnAlias, fullEntityName, attributePath );
		}

		throw new IllegalArgumentException(
				String.format(
						Locale.ROOT,
						"Specified attribute mapping [%s.%s] not a basic attribute: %s",
						fullEntityName,
						attributePath,
						attributeMapping

View on GitHub (pinned to fad1729dce)

Solutions

  1. No entity mapping exists for the given name. Check the entity name and that the entity class is mapped/scanned.

When it happens

Trigger: A runtime precondition of the Hibernate query API is violated: Could not locate entity mapping : <value>

Common situations: Application code or configuration calls the query API in a way that violates its documented contract; the interpolated values in the message identify the offending input.


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