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/RefreshEvent.java:37
*
* @see org.hibernate.Session#refresh
*/
public class RefreshEvent extends AbstractSessionEvent {
private final Object object;
private String entityName;
private LockOptions lockOptions = new LockOptions(
LockMode.READ,
Timeouts.WAIT_FOREVER_MILLI,
PessimisticLockScope.NORMAL,
Locking.FollowOn.ALLOW
);
public RefreshEvent(@Nonnull Object object, @Nonnull EventSource source) {
super(source);
if (object == null) {
throw new IllegalArgumentException("Entity may not be null");
}
this.object = object;
}
public RefreshEvent(@Nullable String entityName, @Nonnull Object object, @Nonnull EventSource source){
this(object, source);
this.entityName = entityName;
}
public RefreshEvent(@Nonnull Object object, @Nonnull LockMode lockMode, @Nonnull EventSource source) {
this(object, source);
if (lockMode == null) {
throw new IllegalArgumentException("LockMode may not be null");
}
this.lockOptions.setLockMode(lockMode);
}
public RefreshEvent(@Nonnull Object object, @Nonnull LockOptions lockOptions, @Nonnull EventSource source) {View on GitHub (pinned to fad1729dce)
Solutions
- Check the entity argument for null before calling refresh().
When it happens
Trigger: Thrown when a caller passes a null Entity to the API guarded in RefreshEvent.java:37.
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/231e2d83558708b6.
Report an issue: GitHub.