@@ -173,18 +173,24 @@ public static TransactionOption optimisticLock() {
173
173
*
174
174
* <ul>
175
175
* <li>{@link ReadLockMode#PESSIMISTIC}: Read locks are acquired immediately on read. This mode
176
- * primarily applies to transactions with {@code SERIALIZABLE} isolation.
176
+ * only applies to {@code SERIALIZABLE} isolation. This mode prevents concurrent
177
+ * modifications by locking data throughout the transaction. This reduces commit-time aborts
178
+ * due to conflicts but can increase how long transactions wait for locks and the overall
179
+ * contention.
177
180
* <li>{@link ReadLockMode#OPTIMISTIC}: Locks for reads within the transaction are not acquired
178
- * on read. Instead the locks are acquired on a commit to validate that read/queried data
179
- * has not changed since the transaction started. If a conflict is detected, the transaction
180
- * will fail. This mode applies to transactions with {@code SERIALIZABLE} isolation.
181
+ * on read. Instead the locks are acquired on commit to validate that read/queried data has
182
+ * not changed since the transaction started. If a conflict is detected, the transaction
183
+ * will fail. This mode only applies to {@code SERIALIZABLE} isolation. This mode defers
184
+ * locking until commit, which can reduce contention and improve throughput. However, be
185
+ * aware that this increases the risk of transaction aborts if there's significant write
186
+ * competition on the same data.
181
187
* <li>{@link ReadLockMode#READ_LOCK_MODE_UNSPECIFIED}: This is the default if no mode is set.
182
188
* The locking behavior depends on the isolation level:
183
189
* <ul>
184
190
* <li>For {@code REPEATABLE_READ} isolation: Locking semantics default to {@code
185
- * OPTIMISTIC}. However, validation checks at commit are only performed for reads
186
- * within queries using {@code SELECT FOR UPDATE}, statements with {@code
187
- * LOCK_SCANNED_RANGES} hints, or DML statements. <br>
191
+ * OPTIMISTIC}. However, validation checks at commit are only performed for queries
192
+ * using {@code SELECT FOR UPDATE}, statements with {@code LOCK_SCANNED_RANGES} hints,
193
+ * and DML statements. <br>
188
194
* Note: It is an error to explicitly set {@code ReadLockMode} when the isolation
189
195
* level is {@code REPEATABLE_READ}.
190
196
* <li>For all other isolation levels: If the read lock mode is not set, it defaults to
0 commit comments