{"record":{"id":"8606e4a1dfc5d6ae","repo":"hibernate/hibernate-orm","slug":"passed-entity-instance-s-is-not-of-expected-typ","errorCode":null,"errorMessage":"Passed entity instance [%s] is not of expected type [%s]","messagePattern":"Passed entity instance \\[(.+?)\\] is not of expected type \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeEnhancementMetadataPojoImpl.java","lineNumber":213,"sourceCode":"\tprivate static void clearDirtyAttributes(final SelfDirtinessTracker entity) {\n\t\tentity.$$_hibernate_clearDirtyAttributes();\n\t}\n\n\tprivate static void useTracker(final ManagedEntity entity) {\n\t\tentity.$$_hibernate_setUseTracker( true );\n\t}\n\n\t@Override\n\tpublic LazyAttributeLoadingInterceptor injectInterceptor(\n\t\t\tObject entity,\n\t\t\tObject identifier,\n\t\t\tSharedSessionContractImplementor session) {\n\t\tif ( !enhancedForLazyLoading ) {\n\t\t\tthrow new NotInstrumentedException( \"Entity class [\" + entityClass.getName() + \"] is not enhanced for lazy loading\" );\n\t\t}\n\n\t\tif ( !entityClass.isInstance( entity ) ) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"Passed entity instance [%s] is not of expected type [%s]\",\n\t\t\t\t\t\t\tentity,\n\t\t\t\t\t\t\tgetEntityName()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tfinal var interceptor = new LazyAttributeLoadingInterceptor(\n\t\t\t\tlazyAttributeLoadingInterceptorState,\n\t\t\t\tidentifier,\n\t\t\t\tsession\n\t\t);\n\t\tinjectInterceptor( entity, interceptor, session );\n\t\treturn interceptor;\n\t}\n\n\t@Override\n\tpublic void injectEnhancedEntityAsProxyInterceptor(","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeEnhancementMetadataPojoImpl.java#L195-L231","documentation":"Error \"Passed entity instance [%s] is not of expected type [%s]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Bytecode enhancement, proxy creation, or lazy interception is applied to an incompatible class or configuration.","commonSituations":"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.","solutions":["Pass an instance of the declared entity type; check for class-loading duplicates or proxies of the wrong class."],"exampleFix":"Pass an instance of the declared entity type; check for class-loading duplicates or proxies of the wrong class.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}