-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JDBC 라이브러리 구현하기 - 4단계] 준팍(박준현) 미션 제출합니다. #607
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 준팍!
마지막까지 고생 많으시네요
간단한 질믄들이 있어서 rc 보냅니다!
|
||
@Override | ||
public void changePassword(long id, String newPassword, String createBy) { | ||
transactionManager.execute(() -> userService.changePassword(id, newPassword, createBy)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추후 발생할 수 있는 트랜잭션 분리를 생각해보시는 것도 재밌을 것 같네요😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 무엇에 관한 질문인지 이해를 못했는데
다시 설명해주실 수 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 Transactional의 required_new를 구현하는 것에 대한 얘기였어요
app/src/main/java/com/techcourse/support/jdbc/init/DatabasePopulatorUtils.java
Show resolved
Hide resolved
@@ -31,7 +32,7 @@ void setUp() { | |||
@Test | |||
void testChangePassword() { | |||
final var userHistoryDao = new UserHistoryDao(jdbcTemplate); | |||
final var userService = new UserService(userDao, userHistoryDao); | |||
final var userService = new AppUserService(userDao, userHistoryDao); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기선 AppUserService를 테스트하셨군요
TxUserService를 통해 테스트할 수 있었을텐데 AppUserService를 테스트하신 이유는 무엇일까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 내에서 Transaction 관련한 로직이 없기 때문에,
검증 대상에는 AppUserService이 더 적합하다고 생각했습니다!
Connection connection = DataSourceUtils.getConnection(dataSource); | ||
|
||
try { | ||
connection.setReadOnly(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이건 무엇일까요? 어떤 장점이 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java Connection의 ReadOnly로 설정하면, 애플리케이션이 데이터베이스에서 데이터를 읽기만 하고
쓰기 작업을 수행하지 않으려는 의도를 나타낼 수 있습니다.
이로 인해 Database driver가 성능 최적화 작업을 할 수 있어 성능이 향상되는 효과가 있다네요 ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 @Transactional
과 목적은 비슷하지만, 수행되는 계층이 다르다라고 이해했습니다. ㅎㅎ
try { | ||
connection.rollback(); | ||
} catch (SQLException e) { | ||
throw new TransactionException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
롤백에서 예외가 터진다면 기존에 터진 예외는 씹힐텐데 이 부분 어떻게 생각하시나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇겠군요 👍 해당 부분도 수정했어야 했는데 깜빡했네여 ㅠ
jdbc/src/main/java/org/springframework/transaction/support/TransactionManager.java
Show resolved
Hide resolved
...src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java
Show resolved
Hide resolved
|
||
// then | ||
verify(command, times(1)).run(); | ||
verify(connection, times(1)).setAutoCommit(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify를 사용하셨네요!
준팍은 mock테스트를 어떤 경우에 사용하시나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제어 가능한 테스트 환경이 필요하거나 테스트 속도를 관리하고 싶을때 사용하는 편입니다!
이번 미션에서는 mock을 사용하여 여러 상황을 쉽게 만들고, 테스트 할 수 있다는 점 때문에 애용했습니다 ㅎㅎ
오래기다리셨습니다 에밀...
살아서 돌아왔습니다...
1,2 단계 질문
3단계 질문
잘 부탁드립니다 에밀~!!