{"record":{"id":"b0032a4eb1a3027d","repo":"hibernate/hibernate-orm","slug":"skip-locked-is-not-valid-option-for-lock","errorCode":null,"errorMessage":"Skip-locked is not valid option for #lock","messagePattern":"Skip-locked is not valid option for #lock","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java","lineNumber":39,"sourceCode":"public 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 */\n\t@Deprecated(since = \"7\", forRemoval = true)\n\tpublic LockEvent(@Nonnull Object object, @Nonnull LockMode lockMode, @Nonnull EventSource source) {\n\t\tthis( object, lockMode.toLockOptions(), source );\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/LockEvent.java#L21-L57","documentation":"Error \"Skip-locked is not valid option for #lock\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when SKIP_LOCKED is requested for an operation that does not support it.","commonSituations":"Typical situations: applying lock options intended for queries to a #lock call; dialect/feature mismatch for skip-locked.","solutions":["Remove LockOptions.setSkipLocked(true) when using Session.lock(); skip-locked is only valid for queries.","Apply skip-locked via query hints or Query.setLockOptions on a selection query instead."],"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"}