hibernate/hibernate-orm · error · IllegalArgumentException
LockOptions may not be null
Error message
LockOptions may not be null
What it means
Error "LockOptions may not be null" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java:35
* @author Steve Ebersole
*
* @see org.hibernate.Session#lock
*/
public class LockEvent extends AbstractSessionEvent {
public static final String ILLEGAL_SKIP_LOCKED = "Skip-locked is not valid option for #lock";
private Object object;
private final LockOptions lockOptions;
private String entityName;
public LockEvent(@Nullable String entityName, @Nonnull Object object, @Nonnull LockOptions lockOptions, @Nonnull EventSource source) {
super(source);
if (object == null) {
throw new IllegalArgumentException( "Entity may not be null" );
}
if (lockOptions == null) {
throw new IllegalArgumentException( "LockOptions may not be null" );
}
if ( lockOptions.getLockMode() == LockMode.UPGRADE_SKIPLOCKED
|| lockOptions.getTimeout().milliseconds() == Timeouts.SKIP_LOCKED_MILLI ) {
throw new IllegalArgumentException( ILLEGAL_SKIP_LOCKED );
}
this.entityName = entityName;
this.object = object;
this.lockOptions = lockOptions;
}
public LockEvent(@Nonnull Object object, @Nonnull LockOptions lockOptions, @Nonnull EventSource source) {
this( null, object, lockOptions, source );
}
/**
* @deprecated Use {@linkplain LockEvent#LockEvent(Object, LockOptions, EventSource)} instead.
*/View on GitHub (pinned to fad1729dce)
Solutions
- Pass a non-null LockOptions instance (e.g. LockOptions.NONE or LockOptions.READ) to the lock operation.
When it happens
Trigger: Thrown when a caller passes a null LockOptions to the API guarded in LockEvent.java:35.
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/04bff1ddb5846d9b.
Report an issue: GitHub.