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

[4단계 - JDBC 라이브러리 구현하기] 포케(이무송) 미션 제출합니다. #878

Open
wants to merge 25 commits into
base: fromitive
Choose a base branch
from

Conversation

fromitive
Copy link
Member

@fromitive fromitive commented Oct 14, 2024

안녕하세요 뽀로로!

4단계 미션 제출합니다.

아직 학습테스트 부분은 수행하지 않았어서 리뷰 후에 업로드 하도록 하겠습니다..!

4단계 마지막! 잘 부탁드려요 👋


학습테스트 반영했습니다 😄

@fromitive fromitive self-assigned this Oct 14, 2024
Copy link

@jcoding-play jcoding-play left a comment

Choose a reason for hiding this comment

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

안녕하세요 포케~ 늦은 리뷰 죄송합니당 😭

스크린샷 2024-10-21 오후 7 29 53

테스트가 제대로 동작하지 않는 것으로 보이는데, 한번 확인해주시고 리뷰 요청주세요~~

}

@Override
@Transactional

Choose a reason for hiding this comment

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

TxUserService를 통해 @Transactional 동작 원리를 구현했는데, @Transactional 어노테이션을 넣는게 맞나요?? 😀

Copy link
Member Author

Choose a reason for hiding this comment

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

이부분 놓쳤네요 😅 반영 완료했습니다!!

Copy link
Member Author

Choose a reason for hiding this comment

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


public abstract class TransactionSynchronizationManager {

private static final ThreadLocal<Map<DataSource, Connection>> resources = new ThreadLocal<>();
private static final ThreadLocal<Map<DataSource, Connection>> resources = ThreadLocal.withInitial(HashMap::new);

Choose a reason for hiding this comment

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

👍👍👍

public static void releaseConnection(Connection connection, DataSource dataSource) {
public static void releaseConnection(DataSource dataSource) {

Choose a reason for hiding this comment

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

분리된 이유를 설명해주실 수 있나요??ㅎㅎ

Copy link
Member Author

Choose a reason for hiding this comment

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

jdbctemplate에서 execute메서드를 실행할 때 트렌젝션의 유무의 따라 커넥션을 닫는 여부를 결정해야 하는데,

트렌젝션이 설정되어 있으면 롤백을 위해 커넥션을 닫으면 안되서 분리하게 되었습니다..!

Comment on lines 32 to 35
Connection connection = TransactionSynchronizationManager.getResource(dataSource);
if (connection.getAutoCommit()) {
connection.close();
}

Choose a reason for hiding this comment

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

만약 반환받은 connection이 null이라면 예외가 발생할 것 같아요~!

Copy link
Member Author

Choose a reason for hiding this comment

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

해당부분 반영 했습니다~~

fix: get을 할때 값 존재 여부를 검증

@fromitive
Copy link
Member Author

안녕하세요 뽀로로~

테스트가 깨져있었군요..! 해당 오류는 TransactionSynchronizationManager에서 자원을 해제하지 않아서 발생하고 있었던 문제여서 아래의 커밋으로 해결했습니다!
refactor: close()시 TransactionSynchronizationManager에서도 해제 하도록 변경

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