{"record":{"id":"ea84f33ca7fcc241","repo":"hibernate/hibernate-orm","slug":"natural-id-value-naturalidvalue-was-not-an-arr","errorCode":null,"errorMessage":"Natural-id value [{naturalIdValue}] was not an array as expected","messagePattern":"Natural-id value \\[(.+?)\\] was not an array as expected","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java","lineNumber":186,"sourceCode":"\t@Override\n\tpublic boolean isNormalized(Object incoming) {\n\t\treturn incoming instanceof Object[];\n\t}\n\n\t@Override\n\tpublic void validateInternalForm(Object naturalIdValue) {\n\t\tif ( naturalIdValue != null ) {\n\t\t\t// should be an array, with a size equal to the number of attributes making up this compound natural-id\n\t\t\tif ( naturalIdValue instanceof Object[] values ) {\n\t\t\t\tif ( values.length != attributes.size() ) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\t\"Natural-id value [\" + naturalIdValue + \"] did not contain the expected number of elements [\"\n\t\t\t\t\t\t\t+ attributes.size() + \"]\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Natural-id value [\" + naturalIdValue + \"] was not an array as expected\" );\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic int calculateHashCode(Object value) {\n\t\tif ( value == null ) {\n\t\t\treturn 0;\n\t\t}\n\t\telse {\n\t\t\tfinal var values = (Object[]) value;\n\t\t\tint hashcode = 0;\n\t\t\tfor ( int i = 0; i < attributes.size(); i++ ) {\n\t\t\t\tfinal Object o = values[i];\n\t\t\t\tif ( o != null ) {\n\t\t\t\t\thashcode = 27 * hashcode\n\t\t\t\t\t\t\t+ ((JavaType) attributes.get( i ).getExpressibleJavaType()).extractHashCode( o );","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java#L168-L204","documentation":"Error \"Natural-id value [{naturalIdValue}] was not an array as expected\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a compound natural-id value is passed as a scalar instead of an array of per-attribute values.","commonSituations":"See trigger scenarios.","solutions":["Supply compound natural-id values as an array (Object[]) with one element per natural-id attribute."],"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"}