-
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 라이브러리 구현하기 - 1단계] 매튜(김재연) 미션 제출합니다. #376
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.
안녕하세요! 잘 지내셨나요 매! 재연씨!
임무를 잘 수행해 주셨군요
제가 드린 피드백은 리팩토링 관련이고 2단계의 주제가 리팩토링이기 때문에 머지해드릴테니 2단계를 진행하면서 같이 반영해 주세요
그럼 이만🚀
} catch (SQLException e) { | ||
throw new RuntimeException(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.
아예 RowMapper라는 커스텀 함수형 인터페이스를 정의하는 것은 어떨까요?
재사용하기 더 편할 것 같습니다
List<User> user = jdbcTemplate.query(sql, rowMapper, id); | ||
validateSingleInquiry(user); | ||
|
||
try { | ||
if (pstmt != null) { | ||
pstmt.close(); | ||
} | ||
} catch (SQLException ignored) {} | ||
return user.get(0); |
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.
Dao에서 매번 리스트를 반환받아서 검증하고, 0번 인덱스를 반환하기 보다
jdbctemplate에서 findById를 만들고 이쪽으로 옮기는 것이 재사용하기 좋지 않을까요?
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.
알러뷰
List<User> user = jdbcTemplate.query(sql, rowMapper, account); | ||
validateSingleInquiry(user); | ||
|
||
return user.get(0); |
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으로 옮길 수 있을 것 같습니다
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.
알러뷰
@@ -14,4 +21,54 @@ public class JdbcTemplate { | |||
public JdbcTemplate(final DataSource dataSource) { | |||
this.dataSource = dataSource; | |||
} | |||
|
|||
public void update(String sql, Object... parameters) { | |||
try (Connection connection = dataSource.getConnection(); |
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.
가변인자 👍 try-with-resource 👍
} | ||
} | ||
|
||
public <T> List<T> query( |
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.
제네릭 👍
안녕하세요! 오랜만입니다. 기무사 출신! 마! 규성씨..
마! 규성씨에게 코드를 보여줘야 한다니 제 생에 이렇게나 떨리는 순간이 있었나 싶군요..
마! 규성씨의 그 때 그 시절처럼 제 코드를 샅샅이 뒤져봐주시고 따끔한 피드백 주세요!
마! 규성씨.. 따끔한 피드백에 미리 감사드립니다.