From 50829c9fdce91309118a2dfa2ebd8cd9bcf43437 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 13 Jan 2016 14:11:13 +0100 Subject: [PATCH] Shared EntityManager does not insist on actualTransactionActive flag anymore Issue: SPR-13838 --- .../springframework/orm/jpa/SharedEntityManagerCreator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index 3bf9e11a351..da262d026ca 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -272,7 +272,8 @@ public abstract class SharedEntityManagerCreator { else if (transactionRequiringMethods.contains(method.getName())) { // We need a transactional target now, according to the JPA spec. // Otherwise, the operation would get accepted but remain unflushed... - if (target == null || !TransactionSynchronizationManager.isActualTransactionActive()) { + if (target == null || (!TransactionSynchronizationManager.isActualTransactionActive() && + !target.getTransaction().isActive())) { throw new TransactionRequiredException("No EntityManager with actual transaction available " + "for current thread - cannot reliably process '" + method.getName() + "' call"); }