hibernate/hibernate-orm · error · IllegalArgumentException
null key for collection: {}
Error message
null key for collection: {} What it means
Error "null key for collection: {}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/HistoryCollectionRowMutationHelper.java:56
this.mutationTarget = mutationTarget;
this.attributeMapping = mutationTarget.getTargetPart();
this.temporalMapping = attributeMapping.getTemporalMapping();
this.historyTableName = historyTableName;
this.currentTableName = mutationTarget.getCollectionTableMapping().getTableName();
this.indexColumnIsSettable = indexColumnIsSettable;
this.elementColumnIsSettable = elementColumnIsSettable;
this.indexIncrementer = indexIncrementer;
}
void bindInsertValues(
PersistentCollection<?> collection,
Object key,
Object rowValue,
int rowPosition,
SharedSessionContractImplementor session,
JdbcValueBindings jdbcValueBindings) {
if ( key == null ) {
throw new IllegalArgumentException( "null key for collection: " + mutationTarget.getRolePath() );
}
attributeMapping.getKeyDescriptor().getKeyPart().decompose(
key,
0,
jdbcValueBindings,
null,
this::bindSetValue,
session
);
final var identifierDescriptor = attributeMapping.getIdentifierDescriptor();
if ( identifierDescriptor != null ) {
identifierDescriptor.decompose(
collection.getIdentifier( rowValue, rowPosition ),
0,
jdbcValueBindings,
null,
this::bindSetValue,View on GitHub (pinned to fad1729dce)
Solutions
- Ensure the owning entity's identifier is non-null before the history collection rows are written (persist the owner first).
When it happens
Trigger: Thrown when mutating a history collection row with a null collection key, indicating the owner entity has no identifier value.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/8f58270545ade6a2.
Report an issue: GitHub.