{"record":{"id":"8ffb0ca875a2a236","repo":"hibernate/hibernate-orm","slug":"invalid-lock-mode-write","errorCode":null,"errorMessage":"Invalid lock mode: WRITE","messagePattern":"Invalid lock mode: WRITE","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/LoadEvent.java","lineNumber":90,"sourceCode":"\t\tsuper( source );\n\t\tthis.entityId = entityId;\n\t\tthis.entityClassName = entityClassName;\n\t\tthis.instanceToLoad = instanceToLoad;\n\t\tthis.lockOptions = lockOptions;\n\t\tthis.isAssociationFetch = isAssociationFetch;\n\t\tthis.readOnly = readOnly;\n\t\tvalidate();\n\t}\n\n\t@Internal\n\tpublic void validate() {\n\t\tif ( entityId == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Identifier may not be null\" );\n\t\t}\n\n\t\tfinal var lockMode = lockOptions.getLockMode();\n\t\tif ( lockMode == LockMode.WRITE ) {\n\t\t\tthrow new IllegalArgumentException( \"Invalid lock mode: \" + LockMode.WRITE );\n\t\t}\n\t\telse if ( lockMode == null ) {\n\t\t\tlockOptions.setLockMode( LockMode.NONE );\n\t\t}\n\t}\n\n\t@Nonnull\n\tpublic Object getEntityId() {\n\t\treturn entityId;\n\t}\n\n\t@Internal\n\tpublic void setEntityId(@Nonnull Object entityId) {\n\t\tthis.entityId = entityId;\n\t}\n\n\t@Nullable\n\tpublic String getEntityClassName() {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/LoadEvent.java#L72-L108","documentation":"Error \"Invalid lock mode: WRITE\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an unsupported LockMode is supplied for the attempted lock operation.","commonSituations":"Typical situations: passing LockMode.WRITE where it is not permitted; a lock mode computed from user input without validation.","solutions":["Do not use LockMode.WRITE with load(); WRITE is reserved for internal use during insert/update.","Use PESSIMISTIC_WRITE or another supported lock mode for explicit locking on load."],"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"}