hibernate/hibernate-orm · error · IllegalArgumentException

Not a managed type

Error message

Not a managed type: ${cls}

What it means

Spec-mandated IllegalArgumentException from the JPA metamodel managedType(Class) accessor: findManagedType returned null because the given Java class is not a managed type (entity, embeddable or mapped superclass) known to this metamodel. The faulty input is the Class argument, typically an unannotated class or one from a different persistence unit.

Solutions

  1. Use a managed type (entity/mapped-superclass/embeddable class); ensure the class is included in the persistence unit.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown when managedType() is called with a Class that has no managed type in the JPA metamodel.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java:263

			@SuppressWarnings("unchecked") // Safe, we checked it
			final var type = (ManagedDomainType<X>) domainType;
			return type;
		}
	}

	@Override
	@Nullable
	public <X> ManagedDomainType<X> findManagedType(Class<X> cls) {
		return checkDomainType( cls, managedTypeByClass.get( cls ) );
	}

	@Override
	@Nonnull
	public <X> ManagedDomainType<X> managedType(@Nonnull Class<X> cls) {
		final var type = findManagedType( cls );
		if ( type == null ) {
			// per JPA
			throw new IllegalArgumentException( "Not a managed type: " + cls );
		}
		return type;
	}

	@Override
	@Nullable
	public <X> EntityDomainType<X> findEntityType(Class<X> cls) {
		return checkDomainType( cls, managedTypeByClass.get( cls ) )
					instanceof EntityDomainType<X> entityDomainType
				? entityDomainType
				: null;
	}

	@Override
	@Nonnull
	public <X> EntityDomainType<X> entity(@Nonnull Class<X> cls) {
		final var entityType = findEntityType( cls );
		if ( entityType == null ) {

View on GitHub (pinned to fad1729dce)