Skip to content

Commit c27c8b0

Browse files
committed
refactor: 커넥션 바인딩 로직 위치 변경
1 parent 02e2819 commit c27c8b0

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

app/src/main/java/com/techcourse/aop/TransactionHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private Object invokeWithTransaction(final Method method, final Object[] args) t
5151

5252
try {
5353
conn = DataSourceUtils.getConnection(dataSource);
54+
TransactionSynchronizationManager.bindResource(dataSource, conn);
5455
originalAutoCommit = conn.getAutoCommit();
5556
conn.setAutoCommit(false);
5657

jdbc/src/main/java/com/interface21/jdbc/datasource/DataSourceUtils.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ public static Connection getConnection(DataSource dataSource) throws CannotGetJd
1818
}
1919

2020
try {
21-
connection = dataSource.getConnection();
22-
TransactionSynchronizationManager.bindResource(dataSource, connection);
23-
return connection;
21+
return dataSource.getConnection();
2422
} catch (SQLException ex) {
2523
throw new CannotGetJdbcConnectionException("Failed to obtain JDBC Connection", ex);
2624
}

0 commit comments

Comments
 (0)