Skip to content

Commit d539d49

Browse files
committed
add a comment explaining motivation for @beikov's fix
1 parent d829a34 commit d539d49

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,9 @@ public <T> T find(EntityGraph<T> entityGraph, Object primaryKey, FindOption... o
25702570
}
25712571

25722572
private void checkTransactionNeededForLock(LockMode lockMode) {
2573+
// OPTIMISTIC and OPTIMISTIC_FORCE_INCREMENT require a transaction
2574+
// because they involve a version check at the end of the transaction
2575+
// All flavors of PESSIMISTIC lock also clearly require a transaction
25732576
if ( lockMode.greaterThan( LockMode.READ ) ) {
25742577
checkTransactionNeededForUpdateOperation();
25752578
}

0 commit comments

Comments
 (0)