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/AuditCollectionRowMutationHelper.java:62
this.auditTableName = auditTableName;
this.changesetIdMapping = changesetIdMapping;
this.modificationTypeMapping = modificationTypeMapping;
this.indexColumnIsSettable = indexColumnIsSettable;
this.elementColumnIsSettable = elementColumnIsSettable;
this.indexIncrementer = indexIncrementer;
this.useServerTransactionTimestamps = useServerTransactionTimestamps;
}
void bindInsertValues(
PersistentCollection<?> collection,
Object key,
Object rowValue,
int rowPosition,
ModificationType modificationType,
SharedSessionContractImplementor session,
JdbcValueBindings jdbcValueBindings) {
if ( key == null ) {
throw new IllegalArgumentException( "null key for collection: " + mutationTarget.getRolePath() );
}
decomposeRowIdentity(
collection,
key,
rowValue,
rowPosition,
session,
jdbcValueBindings,
ParameterUsage.SET
);
if ( !useServerTransactionTimestamps ) {
jdbcValueBindings.bindValue(
session.getCurrentChangesetIdentifier(),
auditTableName,
changesetIdMapping.getSelectionExpression(),
ParameterUsage.SETView on GitHub (pinned to fad1729dce)
Solutions
- Ensure the collection's owner entity is loaded and its key is set before triggering collection row mutation (e.g. do not flush orphan audit collections).
When it happens
Trigger: Thrown when mutating an audit 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/36c9947294e10a7e.
Report an issue: GitHub.