Skip to content

Commit

Permalink
refactor: 트랜잭션 종료 후 setAutoCommit(true) 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
xxeol2 committed Oct 11, 2023
1 parent d655b03 commit 0b7c957
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private <T> T executeTransaction(Supplier<T> transactionExecutor) {
conn.setAutoCommit(false);
result = transactionExecutor.get();
conn.commit();
conn.setAutoCommit(true);
} catch (final SQLException e) {
rollBack(e, TransactionSynchronizationManager.getResource(dataSource));
} finally {
Expand All @@ -42,9 +43,10 @@ private <T> T executeTransaction(Supplier<T> transactionExecutor) {
return result;
}

private void rollBack(final SQLException e, final Connection connection) {
private void rollBack(final SQLException e, final Connection conn) {
try {
connection.rollback();
conn.rollback();
conn.setAutoCommit(true);
throw new DataAccessException(e);
} catch (final SQLException exception) {
throw new DataAccessException(exception);
Expand Down

0 comments on commit 0b7c957

Please sign in to comment.