Skip to content

Commit d829a34

Browse files
committed
Fix wrong transaction requirement check for lock
FYI @gavinking, this reverts a part of what you have done in hibernate#8866 which causes JPA TCK test failure of ee.jakarta.tck.persistence.core.entityManager2.Client2.lockTransactionRequiredExceptionTest
1 parent ba5ba88 commit d829a34

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ public <T> T find(EntityGraph<T> entityGraph, Object primaryKey, FindOption... o
25702570
}
25712571

25722572
private void checkTransactionNeededForLock(LockMode lockMode) {
2573-
if ( !LockMode.PESSIMISTIC_READ.greaterThan( lockMode ) ) {
2573+
if ( lockMode.greaterThan( LockMode.READ ) ) {
25742574
checkTransactionNeededForUpdateOperation();
25752575
}
25762576
}

hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/FlushAndTransactionTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public void testAlwaysTransactionalOperations() {
4848
catch (TransactionRequiredException e) {
4949
//success
5050
}
51-
em.lock( book, LockModeType.READ );
5251
try {
53-
em.lock( book, LockModeType.PESSIMISTIC_READ );
52+
em.lock( book, LockModeType.READ );
5453
fail( "lock has to be inside a Tx" );
5554
}
5655
catch (TransactionRequiredException e) {

0 commit comments

Comments
 (0)