Skip to content

Commit de11cd8

Browse files
committed
EclipseLinkJpaDialect passes custom isolation level on to EclipseLink's DatabaseLogin configuration
Issue: SPR-12319
1 parent c7e7d11 commit de11cd8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,12 +74,21 @@ public void setLazyDatabaseTransaction(boolean lazyDatabaseTransaction) {
7474
public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition)
7575
throws PersistenceException, SQLException, TransactionException {
7676

77-
super.beginTransaction(entityManager, definition);
77+
UnitOfWork uow = entityManager.unwrap(UnitOfWork.class);
78+
79+
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
80+
// Pass custom isolation level on to EclipseLink's DatabaseLogin configuration
81+
uow.getLogin().setTransactionIsolation(definition.getIsolationLevel());
82+
}
83+
84+
entityManager.getTransaction().begin();
85+
7886
if (!definition.isReadOnly() && !this.lazyDatabaseTransaction) {
7987
// Begin an early transaction to force EclipseLink to get a JDBC Connection
8088
// so that Spring can manage transactions with JDBC as well as EclipseLink.
81-
entityManager.unwrap(UnitOfWork.class).beginEarlyTransaction();
89+
uow.beginEarlyTransaction();
8290
}
91+
8392
return null;
8493
}
8594

0 commit comments

Comments
 (0)