Skip to content
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단계] 마코(이규성) 미션 제출합니다. #594

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

aak2075
Copy link

@aak2075 aak2075 commented Oct 9, 2023

안녕하세요 스플릿!

트랜잭션 동기화는 이전 단계에서 이미 수행해서 트랜잭션 서비스 추상화만 구현했습니다!

jdbc 모듈에 TransactionTemplate을 만들어서 트랜잭션 관련 템플릿을 구현하고 콜백을 받아 트랜잭션을 수행하도록 했습니다.

이번 리뷰도 잘 부탁드립니다~

@aak2075 aak2075 requested a review from splitCoding October 9, 2023 16:08
@aak2075 aak2075 self-assigned this Oct 9, 2023
Copy link

@splitCoding splitCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

마코 고생많으셨어요!! 👍
레거시가 남은 부분이 있는 것 같아 Request Change 요청드려요!!😁

Comment on lines 34 to 57
public void changePassword(final long id, final String newPassword, final String createBy) {
final var user = findById(id);
user.changePassword(newPassword);

final var dataSource = DataSourceConfig.getInstance();
final var connection = DataSourceUtils.getConnection(dataSource);
try {
connection.setAutoCommit(false);

userDao.update(user);
userHistoryDao.log(new UserHistory(user, createBy));

connection.commit();
} catch (SQLException e) {
try {
connection.rollback();
throw new DataAccessException(e);
} catch (SQLException e2) {
throw new DataAccessException(e2);
}
} finally {
DataSourceUtils.releaseConnection(dataSource);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요구사항인 인터페이스를 활용하여 트랜잭션 서비스를 추상화하여 비즈니스 로직과 데이터 액세스 로직을 분리해보자. 가 지켜지지 않은 것 같아요!!😭

( 데이터 액세스 로직을 해당 TransactionTemplate 에서 이미 다 처리하셨는데 아마 기조 로직을 삭제하지 않으신것 같아요ㅎㅎ )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TxUserService는 트랜잭션을 사용하고, AppUserService는 트랜잭션을 사용하지 않는건데 트랜잭션 코드가 남아있었네요ㅎㅎ 지워줬습니다!

Comment on lines +15 to +33
public static void execute(Runnable transactionCallback, DataSource dataSource) {
final var connection = DataSourceUtils.getConnection(dataSource);
try {
connection.setAutoCommit(false);

transactionCallback.run();

connection.commit();
} catch (SQLException e) {
try {
connection.rollback();
throw new DataAccessException(e);
} catch (SQLException e2) {
throw new DataAccessException(e2);
}
} finally {
DataSourceUtils.releaseConnection(dataSource);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에서도 템플릿 콜팩 패턴 사용!!!👍 매우 좋은 방법인 것 같아요!!!😊

@aak2075
Copy link
Author

aak2075 commented Oct 11, 2023

레거시가 남아있었군요ㅎㅎㅎㅎ
꼼꼼하게 봐주셔서 감사합니다👍

@splitCoding
Copy link

코드가 깔끔해서 리뷰 내내 항상 보기 편했어요!!😊
마코 고생 많으셨습니다!!

@splitCoding splitCoding merged commit 5ca8e4f into woowacourse:aak2075 Oct 11, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants