Skip to content

3단계 - JDBC 라이브러리 구현(힌트) - 리뷰 요청#180

Merged
ghojeong merged 10 commits intonext-step:headf1rstfrom
headF1rst:step3
Sep 6, 2022
Merged

3단계 - JDBC 라이브러리 구현(힌트) - 리뷰 요청#180
ghojeong merged 10 commits intonext-step:headf1rstfrom
headF1rst:step3

Conversation

@headF1rst
Copy link

안녕하세요 정완님!
이번 미션은 저번 미션에서 구현한 내용과 크게 다르지 않아서 이전에 피드백 해주셨던 내용들을 반영하는데 중점을 두었습니다.

요구사항에는 없지만 정완님의 피드백을 참고하여 Reflectioin을 활용해서 User객체를 생성하는 방식으로 UserDao를 변경해 보았는데요.

정완님의 의도대로 잘 구현했는지는 모르겠네요..ㅎㅎ
그럼 이번 리뷰도 잘 부탁드립니다!

Copy link
Member

@ghojeong ghojeong left a comment

Choose a reason for hiding this comment

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

고산하님!
피드백 반영 매우 훌륭하게 해주셨습니다.
충분한듯 하여 바로 승인 후 머지하겠습니다.

Comment on lines +3 to +7
public class DataAccessException extends RuntimeException {

public DataAccessException(String message, Throwable cause) {
super(message, cause);
}
Copy link
Member

Choose a reason for hiding this comment

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

커스텀 예외 좋습니다. 👍

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);
}
Copy link
Member

Choose a reason for hiding this comment

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

반드시 반영해주실 필요는 없었는데, 대단하십니다. 👍
다만 이 과정에서 RowMapper 인터페이스가 클래스로 바뀌었는데,
인터페이스는 유지하고 인터페이스를 implements 한 별도의 클래스를 선언했으면 더 좋았을 것 같습니다.

result.add(rowMapper.mapRow(rs));
}
return result;
return extractResults(pstmt, new RowMapper<>(type));
Copy link
Member

Choose a reason for hiding this comment

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

RowMapper 에 type 을 명시적으로 넘겨주어서 멤버로 가지고 있게 하는 것도 매우 마음에 듭니다. 👍

@ghojeong ghojeong merged commit 2ecf4f5 into next-step:headf1rst Sep 6, 2022
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