{"record":{"id":"04bff1ddb5846d9b","repo":"hibernate/hibernate-orm","slug":"lockoptions-may-not-be-null","errorCode":null,"errorMessage":"LockOptions may not be null","messagePattern":"LockOptions may not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java","lineNumber":35,"sourceCode":" * @author Steve Ebersole\n *\n * @see org.hibernate.Session#lock\n */\npublic class LockEvent extends AbstractSessionEvent {\n\tpublic static final String ILLEGAL_SKIP_LOCKED = \"Skip-locked is not valid option for #lock\";\n\n\tprivate Object object;\n\tprivate final LockOptions lockOptions;\n\tprivate String entityName;\n\n\tpublic LockEvent(@Nullable String entityName, @Nonnull Object object, @Nonnull LockOptions lockOptions, @Nonnull EventSource source) {\n\t\tsuper(source);\n\n\t\tif (object == null) {\n\t\t\tthrow new IllegalArgumentException( \"Entity may not be null\" );\n\t\t}\n\t\tif (lockOptions == null) {\n\t\t\tthrow new IllegalArgumentException( \"LockOptions may not be null\" );\n\t\t}\n\t\tif ( lockOptions.getLockMode() == LockMode.UPGRADE_SKIPLOCKED\n\t\t\t|| lockOptions.getTimeout().milliseconds() == Timeouts.SKIP_LOCKED_MILLI ) {\n\t\t\tthrow new IllegalArgumentException( ILLEGAL_SKIP_LOCKED );\n\t\t}\n\n\t\tthis.entityName = entityName;\n\t\tthis.object = object;\n\t\tthis.lockOptions = lockOptions;\n\t}\n\n\tpublic LockEvent(@Nonnull Object object, @Nonnull LockOptions lockOptions, @Nonnull EventSource source) {\n\t\tthis( null, object, lockOptions, source );\n\t}\n\n\t/**\n\t * @deprecated Use {@linkplain LockEvent#LockEvent(Object, LockOptions, EventSource)} instead.\n\t */","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java#L17-L53","documentation":"Error \"LockOptions may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a caller passes a null LockOptions to the API guarded in LockEvent.java:35.","commonSituations":"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.","solutions":["Pass a non-null LockOptions instance (e.g. LockOptions.NONE or LockOptions.READ) to the lock operation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}