3단계 - JDBC 라이브러리 구현(힌트) - 리뷰 요청#180
Merged
ghojeong merged 10 commits intonext-step:headf1rstfrom Sep 6, 2022
Merged
Conversation
ghojeong
approved these changes
Sep 6, 2022
Member
ghojeong
left a comment
There was a problem hiding this comment.
고산하님!
피드백 반영 매우 훌륭하게 해주셨습니다.
충분한듯 하여 바로 승인 후 머지하겠습니다.
Comment on lines
+3
to
+7
| public class DataAccessException extends RuntimeException { | ||
|
|
||
| public DataAccessException(String message, Throwable cause) { | ||
| super(message, cause); | ||
| } |
Comment on lines
+23
to
+41
| public T map(ResultSet rs) throws SQLException { | ||
| try { | ||
| Constructor<T> objectConstructor = objectType.getConstructor( | ||
| String.class, String.class, String.class, String.class); | ||
| return newInstance(rs, getParameterNames(objectConstructor), objectConstructor); | ||
| } catch (ReflectiveOperationException e) { | ||
| throw new IllegalStateException("엔티티를 인스턴스화 하는데 실패했습니다.", e); | ||
| } | ||
| } | ||
|
|
||
| private T newInstance(ResultSet rs, String[] parameterNames, Constructor<T> objectConstructor) | ||
| throws InvocationTargetException, InstantiationException, IllegalAccessException, SQLException { | ||
|
|
||
| Object[] args = new Object[parameterNames.length]; | ||
| for (int i = 0; i < parameterNames.length; i++) { | ||
| args[i] = rs.getObject(parameterNames[i]); | ||
| } | ||
| return objectConstructor.newInstance(args); | ||
| } |
Member
There was a problem hiding this comment.
반드시 반영해주실 필요는 없었는데, 대단하십니다. 👍
다만 이 과정에서 RowMapper 인터페이스가 클래스로 바뀌었는데,
인터페이스는 유지하고 인터페이스를 implements 한 별도의 클래스를 선언했으면 더 좋았을 것 같습니다.
| result.add(rowMapper.mapRow(rs)); | ||
| } | ||
| return result; | ||
| return extractResults(pstmt, new RowMapper<>(type)); |
Member
There was a problem hiding this comment.
RowMapper 에 type 을 명시적으로 넘겨주어서 멤버로 가지고 있게 하는 것도 매우 마음에 듭니다. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
안녕하세요 정완님!
이번 미션은 저번 미션에서 구현한 내용과 크게 다르지 않아서 이전에 피드백 해주셨던 내용들을 반영하는데 중점을 두었습니다.
요구사항에는 없지만 정완님의 피드백을 참고하여 Reflectioin을 활용해서 User객체를 생성하는 방식으로 UserDao를 변경해 보았는데요.
정완님의 의도대로 잘 구현했는지는 모르겠네요..ㅎㅎ
그럼 이번 리뷰도 잘 부탁드립니다!