|
|
|
@ -115,6 +115,7 @@ public abstract class DataSourceUtils {
@@ -115,6 +115,7 @@ public abstract class DataSourceUtils {
|
|
|
|
|
Connection con = fetchConnection(dataSource); |
|
|
|
|
|
|
|
|
|
if (TransactionSynchronizationManager.isSynchronizationActive()) { |
|
|
|
|
try { |
|
|
|
|
// Use same Connection for further JDBC actions within the transaction.
|
|
|
|
|
// Thread-bound object will get removed by synchronization at transaction completion.
|
|
|
|
|
ConnectionHolder holderToUse = conHolder; |
|
|
|
@ -132,6 +133,12 @@ public abstract class DataSourceUtils {
@@ -132,6 +133,12 @@ public abstract class DataSourceUtils {
|
|
|
|
|
TransactionSynchronizationManager.bindResource(dataSource, holderToUse); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (RuntimeException ex) { |
|
|
|
|
// Unexpected exception from external delegation call -> close Connection and rethrow.
|
|
|
|
|
releaseConnection(con, dataSource); |
|
|
|
|
throw ex; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return con; |
|
|
|
|
} |
|
|
|
|