{"record":{"id":"2f186cc1eab2f5d3","repo":"hibernate/hibernate-orm","slug":"object-of-type-can-t-be-cast-to-persistentatt","errorCode":null,"errorMessage":"Object of type '{}' can't be cast to PersistentAttributeInterceptable","messagePattern":"Object of type '(.+?)' can't be cast to PersistentAttributeInterceptable","errorType":"exception","errorClass":"ClassCastException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java","lineNumber":262,"sourceCode":"\t\tvoid accept(SelfDirtinessTracker tracker, T optionalParam);\n\t}\n\n\t/**\n\t * Cast the object to PersistentAttributeInterceptable\n\t * (using this is highly preferrable over a direct cast)\n\t * @param entity the entity to cast\n\t * @return the same instance after casting\n\t * @throws ClassCastException if it's not of the right type\n\t */\n\tpublic static PersistentAttributeInterceptable asPersistentAttributeInterceptable(final Object entity) {\n\t\tObjects.requireNonNull( entity );\n\t\tif ( entity instanceof PrimeAmongSecondarySupertypes t ) {\n\t\t\tfinal PersistentAttributeInterceptable e = t.asPersistentAttributeInterceptable();\n\t\t\tif ( e != null ) {\n\t\t\t\treturn e;\n\t\t\t}\n\t\t}\n\t\tthrow new ClassCastException( \"Object of type '\" + entity.getClass() + \"' can't be cast to PersistentAttributeInterceptable\" );\n\t}\n\n\tpublic static PersistentAttributeInterceptable asPersistentAttributeInterceptableOrNull(final Object entity) {\n\t\tif ( entity instanceof PrimeAmongSecondarySupertypes t ) {\n\t\t\treturn t.asPersistentAttributeInterceptable();\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Cast the object to HibernateProxy\n\t * (using this is highly preferrable over a direct cast)\n\t * @param entity the entity to cast\n\t * @return the same instance after casting\n\t * @throws ClassCastException if it's not of the right type\n\t */\n\tpublic static HibernateProxy asHibernateProxy(final Object entity) {\n\t\tObjects.requireNonNull( entity );","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java#L244-L280","documentation":"Error \"Object of type '{}' can't be cast to PersistentAttributeInterceptable\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java:262 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the entity class is bytecode-enhanced or a proper managed type before casting to PersistentAttributeInterceptable","Enable Hibernate bytecode enhancement in the build so managed types implement the interception interfaces"],"exampleFix":null,"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"}