Skip to content

Commit 3c2590d

Browse files
committed
Document limited isolation level support for concurrent transactions
See gh-29997
1 parent 4b55333 commit 3c2590d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaDialect.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@
3636
* Persistence Services (EclipseLink). Developed and tested against EclipseLink 2.7;
3737
* backwards-compatible with EclipseLink 2.5 and 2.6 at runtime.
3838
*
39-
* <p>By default, this class acquires an early EclipseLink transaction with an early
40-
* JDBC Connection for non-read-only transactions. This allows for mixing JDBC and
41-
* JPA/EclipseLink operations in the same transaction, with cross visibility of
39+
* <p>By default, this dialect acquires an early EclipseLink transaction with an
40+
* early JDBC Connection for non-read-only transactions. This allows for mixing
41+
* JDBC and JPA operations in the same transaction, with cross visibility of
4242
* their impact. If this is not needed, set the "lazyDatabaseTransaction" flag to
4343
* {@code true} or consistently declare all affected transactions as read-only.
4444
* As of Spring 4.1.2, this will reliably avoid early JDBC Connection retrieval
4545
* and therefore keep EclipseLink in shared cache mode.
4646
*
47+
* <p><b>NOTE: This dialect supports custom isolation levels with limitations.</b>
48+
* Consistent isolation level handling is only guaranteed when all Spring transaction
49+
* definitions specify a concrete isolation level, without any default transactions
50+
* running concurrently. Otherwise, you may see non-default isolation levels exposed
51+
* to default transactions when custom isolation is used in concurrent transactions.
52+
*
4753
* @author Juergen Hoeller
4854
* @since 2.5.2
4955
* @see #setLazyDatabaseTransaction
@@ -85,7 +91,8 @@ public Object beginTransaction(EntityManager entityManager, TransactionDefinitio
8591
// (since Spring 4.1.2 / revised in 5.3.28)
8692
UnitOfWork uow = entityManager.unwrap(UnitOfWork.class);
8793
DatabaseLogin databaseLogin = uow.getLogin();
88-
// Synchronize on shared DatabaseLogin instance (-> concurrent transactions)
94+
// Synchronize on shared DatabaseLogin instance for consistent isolation level
95+
// set and reset in case of concurrent transactions with different isolation.
8996
synchronized (databaseLogin) {
9097
int originalIsolationLevel = databaseLogin.getTransactionIsolation();
9198
// Apply current isolation level value, if necessary.

0 commit comments

Comments
 (0)