File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
main/java/org/springframework/orm/jpa
test/java/org/springframework/orm/jpa/support Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2014 the original author or authors.
2+ * Copyright 2002-2015 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.
3434import org .apache .commons .logging .Log ;
3535import org .apache .commons .logging .LogFactory ;
3636
37+ import org .springframework .transaction .support .TransactionSynchronizationManager ;
3738import org .springframework .util .ClassUtils ;
3839import org .springframework .util .CollectionUtils ;
3940
@@ -271,8 +272,9 @@ else if (method.getName().equals("unwrap")) {
271272 else if (transactionRequiringMethods .contains (method .getName ())) {
272273 // We need a transactional target now, according to the JPA spec.
273274 // Otherwise, the operation would get accepted but remain unflushed...
274- if (target == null ) {
275- throw new TransactionRequiredException ("No transactional EntityManager available" );
275+ if (target == null || !TransactionSynchronizationManager .isActualTransactionActive ()) {
276+ throw new TransactionRequiredException ("No EntityManager with actual transaction available " +
277+ "for current thread - cannot reliably process '" + method .getName () + "' call" );
276278 }
277279 }
278280
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2014 the original author or authors.
2+ * Copyright 2002-2015 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.
@@ -116,12 +116,12 @@ public void testTransactionCommitWithSharedEntityManagerAndPropagationSupports()
116116 tt .execute (new TransactionCallback () {
117117 @ Override
118118 public Object doInTransaction (TransactionStatus status ) {
119- bean .sharedEntityManager .flush ();
119+ bean .sharedEntityManager .clear ();
120120 return null ;
121121 }
122122 });
123123
124- verify (manager ).flush ();
124+ verify (manager ).clear ();
125125 verify (manager ).close ();
126126 }
127127
You can’t perform that action at this time.
0 commit comments