hibernate/hibernate-orm · error · IllegalArgumentException
Passed entity instance [%s] is not of expected type [%s]
Error message
Passed entity instance [%s] is not of expected type [%s]
What it means
Error "Passed entity instance [%s] is not of expected type [%s]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeEnhancementMetadataPojoImpl.java:213
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;
}
@Override
public void injectEnhancedEntityAsProxyInterceptor(View on GitHub (pinned to fad1729dce)
Solutions
- Pass an instance of the declared entity type; check for class-loading duplicates or proxies of the wrong class.
Example fix
Pass an instance of the declared entity type; check for class-loading duplicates or proxies of the wrong class.
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/8606e4a1dfc5d6ae.
Report an issue: GitHub.