{"record":{"id":"df0ad44e69f37116","repo":"hibernate/hibernate-orm","slug":"object-of-type-can-t-be-cast-to-compositetrac","errorCode":null,"errorMessage":"Object of type '{}' can't be cast to CompositeTracker","messagePattern":"Object of type '(.+?)' can't be cast to CompositeTracker","errorType":"exception","errorClass":"ClassCastException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java","lineNumber":323,"sourceCode":"\t\tthrow new ClassCastException( \"Object of type '\" + entity.getClass() + \"' can't be cast to ManagedEntity\" );\n\t}\n\n\t/**\n\t * Cast the object to CompositeTracker\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 CompositeTracker asCompositeTracker(final Object entity) {\n\t\tObjects.requireNonNull( entity );\n\t\tif ( entity instanceof PrimeAmongSecondarySupertypes t ) {\n\t\t\tfinal CompositeTracker e = t.asCompositeTracker();\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 CompositeTracker\" );\n\t}\n\n\t/**\n\t * Cast the object to CompositeOwner\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 CompositeOwner asCompositeOwner(final Object entity) {\n\t\tObjects.requireNonNull( entity );\n\t\tif ( entity instanceof PrimeAmongSecondarySupertypes t ) {\n\t\t\tfinal CompositeOwner e = t.asCompositeOwner();\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 CompositeOwner\" );","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java#L305-L341","documentation":"Error \"Object of type '{}' can't be cast to CompositeTracker\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java:323 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the embeddable/composite type is bytecode-enhanced so it implements CompositeTracker","Check with instanceof CompositeTracker before casting"],"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"}