{"record":{"id":"9a91fc96364684bb","repo":"hibernate/hibernate-orm","slug":"expected-object-of-type-s-but-found-s-disc","errorCode":null,"errorMessage":"Expected object of type `%s`, but found `%s`; discriminator = %s","messagePattern":"Expected object of type `(.+?)`, but found `(.+?)`; discriminator = (.+?)","errorType":"exception","errorClass":"WrongClassException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityConcreteTypeLoader.java","lineNumber":100,"sourceCode":"\t\t\t\t\t\t\t\tRowTransformerStandardImpl.instance(),\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\tListResultsConsumer.UniqueSemantic.NONE,\n\t\t\t\t\t\t\t\t1\n\t\t\t\t\t\t);\n\n\t\tif ( results.isEmpty() ) {\n\t\t\tthrow new ObjectNotFoundException( entityDescriptor.getEntityName(), id );\n\t\t}\n\t\telse {\n\t\t\tassert results.size() == 1;\n\t\t\tfinal Object result = results.get( 0 );\n\t\t\tfinal var mappingMetamodel = factory.getMappingMetamodel();\n\t\t\tfinal var concreteType =\n\t\t\t\t\tresult instanceof Class<?> concreteClass\n\t\t\t\t\t\t\t? mappingMetamodel.getEntityDescriptor( concreteClass )\n\t\t\t\t\t\t\t: mappingMetamodel.getEntityDescriptor( (String) result );\n\t\t\tif ( !concreteType.isTypeOrSuperType( entityDescriptor ) ) {\n\t\t\t\tthrow new WrongClassException(\n\t\t\t\t\t\tconcreteType.getEntityName(),\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tentityDescriptor.getEntityName(),\n\t\t\t\t\t\tresult\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn concreteType;\n\t\t}\n\t}\n}\n","sourceCodeStart":82,"sourceCodeEnd":111,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityConcreteTypeLoader.java#L82-L111","documentation":"Error \"Expected object of type `%s`, but found `%s`; discriminator = %s\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityConcreteTypeLoader.java:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the discriminator values and inheritance mapping; the row's discriminator maps to a different subclass than requested."],"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"}