hibernate/hibernate-orm · error · NotInstrumentedException

Entity class [{className}] is not enhanced for lazy loading

Error message

Entity class [{className}] is not enhanced for lazy loading

What it means

Error "Entity class [{className}] is not enhanced for lazy loading" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeEnhancementMetadataPojoImpl.java:209

		return entity;
	}

	private static void clearDirtyAttributes(final SelfDirtinessTracker entity) {
		entity.$$_hibernate_clearDirtyAttributes();
	}

	private static void useTracker(final ManagedEntity entity) {
		entity.$$_hibernate_setUseTracker( true );
	}

	@Override
	public LazyAttributeLoadingInterceptor injectInterceptor(
			Object entity,
			Object identifier,
			SharedSessionContractImplementor session) {
		if ( !enhancedForLazyLoading ) {
			throw new NotInstrumentedException( "Entity class [" + entityClass.getName() + "] is not enhanced for lazy loading" );
		}

		if ( !entityClass.isInstance( entity ) ) {
			throw new IllegalArgumentException(
					String.format(
							"Passed entity instance [%s] is not of expected type [%s]",
							entity,
							getEntityName()
					)
			);
		}
		final var interceptor = new LazyAttributeLoadingInterceptor(
				lazyAttributeLoadingInterceptorState,
				identifier,
				session
		);
		injectInterceptor( entity, interceptor, session );
		return interceptor;

View on GitHub (pinned to fad1729dce)

Solutions

  1. Enable bytecode enhancement (hibernate-enhance-maven-plugin/Gradle plugin) for the entity, or avoid lazy no-proxy loading for it.

Example fix

Enable bytecode enhancement (hibernate-enhance-maven-plugin/Gradle plugin) for the entity, or avoid lazy no-proxy loading for it.

When it happens

Trigger: Bytecode enhancement, proxy creation, or lazy interception is applied to an incompatible class or configuration.

Common situations: Build-time enhancement with module-system restrictions, mismatched Hibernate versions between build and runtime, or hibernate.bytecode.provider=none with a model that needs proxies.


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