SpringConnectionProvider throws IllegalStateException when if a transaction is not found.
@@ -24,9 +24,13 @@ | ||
24 | 24 | |
25 | 25 | public Connection getConnection() { |
26 | 26 | ConnectionHolder conHolder = |
27 | - (ConnectionHolder) TransactionSynchronizationManager.getResource( | |
28 | - transactionManager.getDataSource()); | |
27 | + (ConnectionHolder) TransactionSynchronizationManager.getResource( | |
28 | + transactionManager.getDataSource()); | |
29 | 29 | |
30 | + if (conHolder == null) { | |
31 | + throw new IllegalStateException("It seems not to be existing a transaction."); | |
32 | + } | |
33 | + | |
30 | 34 | return conHolder.getConnection(); |
31 | 35 | } |
32 | 36 |