hibernate/hibernate-orm · error · IllegalArgumentException
Entity may not be null
Error message
Entity may not be null
What it means
Error "Entity may not be null" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/MergeEvent.java:41
private Object result;
public MergeEvent(@Nullable String entityName, @Nonnull Object original, @Nonnull EventSource source) {
this(original, source);
this.entityName = entityName;
}
public MergeEvent(@Nullable String entityName, @Nonnull Object original, @Nonnull Object id, @Nonnull EventSource source) {
this(entityName, original, source);
if ( id == null ) {
throw new IllegalArgumentException( "Identifier may not be null" );
}
this.requestedId = id;
}
public MergeEvent(@Nonnull Object object, @Nonnull EventSource source) {
super(source);
if ( object == null ) {
throw new IllegalArgumentException( "Entity may not be null" );
}
this.original = object;
}
@Nonnull
public Object getOriginal() {
return original;
}
public void setOriginal(@Nonnull Object object) {
this.original = object;
}
@Nullable
public Object getRequestedId() {
return requestedId;
}
View on GitHub (pinned to fad1729dce)
Solutions
- Check the entity argument for null before calling merge().
When it happens
Trigger: Thrown when a caller passes a null Entity to the API guarded in MergeEvent.java:41.
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/7730e3929d54ba89.
Report an issue: GitHub.