{"record":{"id":"962c9770360d493e","repo":"hibernate/hibernate-orm","slug":"unexpected-non-null-value-for-embeddable-subtype","errorCode":null,"errorMessage":"Unexpected non-null value for embeddable subtype '%s'","messagePattern":"Unexpected non-null value for embeddable subtype '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java","lineNumber":901,"sourceCode":"\t\t\treturn results;\n\t\t}\n\t}\n\n\t@Override\n\tprotected void setAttributeValues(Object component, Object[] values) {\n\t\tif ( !isPolymorphic() ) {\n\t\t\tsuper.setAttributeValues( component, values );\n\t\t}\n\t\telse {\n\t\t\tfinal String compositeClassName = component.getClass().getName();\n\t\t\tfinal var concreteEmbeddableType = findSubtypeBySubclass( compositeClassName );\n\t\t\tfor ( int i = 0; i < getNumberOfAttributeMappings(); i++ ) {\n\t\t\t\tfinal AttributeMapping attributeMapping = getAttributeMapping( i );\n\t\t\t\tif ( concreteEmbeddableType.declaresAttribute( attributeMapping ) ) {\n\t\t\t\t\tsetValue( component, i, values[i] );\n\t\t\t\t}\n\t\t\t\telse if ( values[i] != null ) {\n\t\t\t\t\tthrow new IllegalArgumentException( String.format(\n\t\t\t\t\t\t\t\"Unexpected non-null value for embeddable subtype '%s'\",\n\t\t\t\t\t\t\tcompositeClassName\n\t\t\t\t\t) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic ModelPart findSubPart(String name, EntityMappingType treatTargetType) {\n\t\treturn EntityDiscriminatorMapping.matchesRoleName( name )\n\t\t\t\t? discriminatorMapping\n\t\t\t\t: super.findSubPart( name, treatTargetType );\n\n\t}\n\n\t@Override\n\tpublic <X, Y> int breakDownJdbcValues(","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddableMappingTypeImpl.java#L883-L919","documentation":"Error \"Unexpected non-null value for embeddable subtype '%s'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when materializing an embeddable whose discriminator indicates one subtype but a non-null value is found for a different subtype's state.","commonSituations":"See trigger scenarios.","solutions":["Set only the discriminator-selected subtype's portion of the embeddable; do not populate values for other subtypes."],"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"}