hibernate/hibernate-orm · error · IllegalArgumentException
Identifier may not be null
Error message
Identifier may not be null
What it means
Error "Identifier may not be null" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/LoadEvent.java:85
@Nullable Object instanceToLoad,
@Nonnull LockOptions lockOptions,
boolean isAssociationFetch,
@Nonnull EventSource source,
@Nullable Boolean readOnly) {
super( source );
this.entityId = entityId;
this.entityClassName = entityClassName;
this.instanceToLoad = instanceToLoad;
this.lockOptions = lockOptions;
this.isAssociationFetch = isAssociationFetch;
this.readOnly = readOnly;
validate();
}
@Internal
public void validate() {
if ( entityId == null ) {
throw new IllegalArgumentException( "Identifier may not be null" );
}
final var lockMode = lockOptions.getLockMode();
if ( lockMode == LockMode.WRITE ) {
throw new IllegalArgumentException( "Invalid lock mode: " + LockMode.WRITE );
}
else if ( lockMode == null ) {
lockOptions.setLockMode( LockMode.NONE );
}
}
@Nonnull
public Object getEntityId() {
return entityId;
}
@Internal
public void setEntityId(@Nonnull Object entityId) {View on GitHub (pinned to fad1729dce)
Solutions
- Ensure the identifier passed to load()/get() is non-null before the call.
- Validate the id value earlier in the call chain where it is produced.
When it happens
Trigger: Thrown when a caller passes a null Identifier to the API guarded in LoadEvent.java:85.
Common situations: Typical situations: calling the method with an uninitialized variable; a lookup that returned null being passed straight through; missing null-checks in application code before invoking Hibernate.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/a7b99a0bbf7ceee7.
Report an issue: GitHub.