{"record":{"id":"8f58270545ade6a2","repo":"hibernate/hibernate-orm","slug":"null-key-for-collection-8f5827","errorCode":null,"errorMessage":"null key for collection: {}","messagePattern":"null key for collection: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/HistoryCollectionRowMutationHelper.java","lineNumber":56,"sourceCode":"\t\tthis.mutationTarget = mutationTarget;\n\t\tthis.attributeMapping = mutationTarget.getTargetPart();\n\t\tthis.temporalMapping = attributeMapping.getTemporalMapping();\n\t\tthis.historyTableName = historyTableName;\n\t\tthis.currentTableName = mutationTarget.getCollectionTableMapping().getTableName();\n\t\tthis.indexColumnIsSettable = indexColumnIsSettable;\n\t\tthis.elementColumnIsSettable = elementColumnIsSettable;\n\t\tthis.indexIncrementer = indexIncrementer;\n\t}\n\n\tvoid bindInsertValues(\n\t\t\tPersistentCollection<?> collection,\n\t\t\tObject key,\n\t\t\tObject rowValue,\n\t\t\tint rowPosition,\n\t\t\tSharedSessionContractImplementor session,\n\t\t\tJdbcValueBindings jdbcValueBindings) {\n\t\tif ( key == null ) {\n\t\t\tthrow new IllegalArgumentException( \"null key for collection: \" + mutationTarget.getRolePath() );\n\t\t}\n\t\tattributeMapping.getKeyDescriptor().getKeyPart().decompose(\n\t\t\t\tkey,\n\t\t\t\t0,\n\t\t\t\tjdbcValueBindings,\n\t\t\t\tnull,\n\t\t\t\tthis::bindSetValue,\n\t\t\t\tsession\n\t\t);\n\n\t\tfinal var identifierDescriptor = attributeMapping.getIdentifierDescriptor();\n\t\tif ( identifierDescriptor != null ) {\n\t\t\tidentifierDescriptor.decompose(\n\t\t\t\t\tcollection.getIdentifier( rowValue, rowPosition ),\n\t\t\t\t\t0,\n\t\t\t\t\tjdbcValueBindings,\n\t\t\t\t\tnull,\n\t\t\t\t\tthis::bindSetValue,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/HistoryCollectionRowMutationHelper.java#L38-L74","documentation":"Error \"null key for collection: {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when mutating a history collection row with a null collection key, indicating the owner entity has no identifier value.","commonSituations":"See trigger scenarios.","solutions":["Ensure the owning entity's identifier is non-null before the history collection rows are written (persist the owner first)."],"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"}