Skip to content

Commit 0b64805

Browse files
committed
explain effect of LockModes on lost updates and non-repeatable reads
1 parent 7010c48 commit 0b64805

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hibernate-core/src/main/java/org/hibernate/LockMode.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@
3434
* which any pessimistic lock is already held has no effect,
3535
* and does not force a version increment.
3636
* <p>
37+
* When an entity is read from the database, its lock mode
38+
* determines whether lost updates and non-repeatable reads
39+
* are possible.
40+
* <ul>
41+
* <li>{@link #NONE} and {@link #READ} prevent lost updates
42+
* only for versioned entities, but do not prevent
43+
* non-repeatable reads, and do not prevent lost updates
44+
* for entities with no version attribute.
45+
* <li>{@link #OPTIMISTIC} and {@link #OPTIMISTIC_FORCE_INCREMENT}
46+
* prevent lost updates and non-repeatable reads only for
47+
* versioned entities.
48+
* <li>{@link #PESSIMISTIC_READ}, {@link #PESSIMISTIC_WRITE},
49+
* and {@link #PESSIMISTIC_FORCE_INCREMENT} prevent lost
50+
* updates and non-repeatable reads for all entities,
51+
* including entities with no version attribute.
52+
* </ul>
53+
* <p>
3754
* This enumeration of lock modes competes with the JPA-defined
3855
* {@link LockModeType}, but offers additional options, including
3956
* {@link #UPGRADE_NOWAIT} and {@link #UPGRADE_SKIPLOCKED}.

0 commit comments

Comments
 (0)