-
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
[4단계 - JDBC 라이브러리 구현하기] 포케(이무송) 미션 제출합니다. #878
base: fromitive
Are you sure you want to change the base?
Conversation
# Conflicts: # app/src/main/java/com/techcourse/service/UserService.java # app/src/test/java/com/techcourse/service/UserServiceTest.java
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.
} | ||
|
||
@Override | ||
@Transactional |
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.
TxUserService를 통해 @Transactional
동작 원리를 구현했는데, @Transactional
어노테이션을 넣는게 맞나요?? 😀
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.
|
||
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); |
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.
👍👍👍
public static void releaseConnection(Connection connection, DataSource dataSource) { | ||
public static void releaseConnection(DataSource dataSource) { |
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.
jdbctemplate에서 execute메서드를 실행할 때 트렌젝션의 유무의 따라 커넥션을 닫는 여부를 결정해야 하는데,
트렌젝션이 설정되어 있으면 롤백을 위해 커넥션을 닫으면 안되서 분리하게 되었습니다..!
Connection connection = TransactionSynchronizationManager.getResource(dataSource); | ||
if (connection.getAutoCommit()) { | ||
connection.close(); | ||
} |
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.
만약 반환받은 connection이 null이라면 예외가 발생할 것 같아요~!
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.
해당부분 반영 했습니다~~
안녕하세요 뽀로로~ 테스트가 깨져있었군요..! 해당 오류는 TransactionSynchronizationManager에서 자원을 해제하지 않아서 발생하고 있었던 문제여서 아래의 커밋으로 해결했습니다! |
안녕하세요 뽀로로!
4단계 미션 제출합니다.
아직 학습테스트 부분은 수행하지 않았어서 리뷰 후에 업로드 하도록 하겠습니다..!4단계 마지막! 잘 부탁드려요 👋
학습테스트 반영했습니다 😄