Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ public Connection getConnection() throws SQLException {
private void openConnection() throws SQLException {
this.connection = DataSourceUtils.getConnection(this.dataSource);
this.autoCommit = this.connection.getAutoCommit();
this.isConnectionTransactional = DataSourceUtils.isConnectionTransactional(this.connection, this.dataSource);

boolean isInActiveTransaction = TransactionSynchronizationManager.isActualTransactionActive();
this.isConnectionTransactional = isInActiveTransaction &&
DataSourceUtils.isConnectionTransactional(this.connection, this.dataSource);

LOGGER.debug(() -> "JDBC Connection [" + this.connection + "] will"
+ (this.isConnectionTransactional ? " " : " not ") + "be managed by Spring");
+ (this.isConnectionTransactional ? " " : " not ") + "be managed by Spring");
}

@Override
public void commit() throws SQLException {
Comment thread
hazendaz marked this conversation as resolved.
if (this.connection != null && !this.isConnectionTransactional && !this.autoCommit) {
Expand Down