Skip to content

Commit c1f233c

Browse files
committed
Shared EntityManager does not insist on actualTransactionActive flag anymore
Issue: SPR-13838 (cherry picked from commit 50829c9)
1 parent 77b8f4d commit c1f233c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -272,7 +272,8 @@ else if (method.getName().equals("unwrap")) {
272272
else if (transactionRequiringMethods.contains(method.getName())) {
273273
// We need a transactional target now, according to the JPA spec.
274274
// Otherwise, the operation would get accepted but remain unflushed...
275-
if (target == null || !TransactionSynchronizationManager.isActualTransactionActive()) {
275+
if (target == null || (!TransactionSynchronizationManager.isActualTransactionActive() &&
276+
!target.getTransaction().isActive())) {
276277
throw new TransactionRequiredException("No EntityManager with actual transaction available " +
277278
"for current thread - cannot reliably process '" + method.getName() + "' call");
278279
}

0 commit comments

Comments
 (0)