-
Notifications
You must be signed in to change notification settings - Fork 56
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
[Spring Data JPA] 한경준 미션 제출합니다. #53
base: hkjbrian
Are you sure you want to change the base?
Conversation
…iguration), ReservationRequest record 변경
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가지 계셨는데 제가 최대한 도움드려보려고 노력했습니다!
우선 1번 내용의 경우 현재 schema.sql 파일을 볼 수가 없는데 삭제된게 아닐까요?? 해당 부분 확인해주시고 수정하셨다면 같이 올려주세요!! 같이 확인해야 문제점을 찾을 수 있을거 같아요!
2번의 경우에 학습테스트 때 사용한 CrudRepository<?, ?>
를 사용하셨는데 이것 말고도 JpaRepository<?, ?>
가 존재한답니다! 두 방법간 차이점은 CrudRepository와 JpaRepository 차이점 를 참고해주세요!
간단하게 설명하자면 두 방법간 반환 방식이 다르기 때문에 제공하는 기능도 다릅니다!
마지막으로 미션을 진행하시면서 예외처리도 함께 진행하면 좋을거 같아요!
마지막 한 주 열심히 해봐요!!!😊
public interface MemberRepository extends CrudRepository<Member, Long> { | ||
|
||
@Override | ||
public Optional<Member> findById(Long id); |
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.
공통리뷰에 나온 Optional을 적용하셨네요👍
} | ||
|
||
public ReservationResponse save(ReservationRequest reservationRequest) { | ||
Reservation reservation = reservationDao.save(reservationRequest); | ||
Reservation reservation = reservationRepository.save(requestToDao(reservationRequest)); |
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.
이 부분에서 requestToDao 메서드를 따로 만드신 이유가 있을까요?? 궁금하네요!!
return reservationDao.findAll().stream() | ||
return StreamSupport.stream(reservationRepository.findAll().spliterator(), false) | ||
.toList() | ||
.stream() | ||
.map(it -> new ReservationResponse(it.getId(), it.getName(), it.getTheme().getName(), it.getDate(), it.getTime().getValue())) |
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.
.map(it -> new ReservationResponse(it.getId(), it.getName(), it.getTheme().getName(), it.getDate(), it.getTime().getValue())) | |
.map(it -> new ReservationResponse( | |
it.getId(), | |
it.getName(), | |
it.getTheme().getName(), | |
it.getDate(), | |
it.getTime().getValue())) |
코드의 길이가 길고 컬럼을 3개 이상 받고 있으니 이렇게 바꾸면 가독성이 더 좋아질 것으로 보여요!
.map(reservation -> new MyReservationResponse( | ||
reservation.getId(), | ||
reservation.getTheme().getName(), | ||
reservation.getDate(), | ||
reservation.getTime().getValue(), | ||
"예약")) |
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.
이 부분은 엄청 깔끔하게 하셨네요!!👍
안녕하세요 리뷰어님 이번 주차도 고생하셨습니다!
역시나 쉽지 않은 미션이네요 .. 현재 5단계까지 구현 완료하였고, 6단계도 구현 진행 중에 있습니다. 마저 구현 완료하게 되면 다시 알려드리겠습니다!
이번주차 커밋 내용
JPA 연관관계 매핑이 올바르게 되었는지.
-> admin/time 으로 접근하였을 때, 현재 시간들이 잘 불러와지지 않는 문제가 있었습니다. TimeService.findall() 메서드를 실행했을 때, DB로부터 List 값은 정상적으로 들어오는데, 이후에 Time ["time"] -> Time["time"] 과 같이 Time 객체가 스스로를 무한 참조하는 문제가 발생했었습니다. Time 객체가 올바르게 설정되었는지, TimeService가 JPA를 올바르게 사용하여 DB에 접근하고 있는지 중점적으로 봐주시면 감사하겠습니다!
미션 요구 사항을 하나씩 만족시켜보려 이것저것 설정 및 버그를 잡다보니 얼렁뚱땅 진행된 부분도 있는 것 같은데 혹시 JPA 관련하여 참고하셨거나 도움되는 내용 있으셨다면 공유해주시면 감사하겠습니다~!