Skip to content
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] 윤성원 미션 제출합니다. #52

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mete0rfish
Copy link

@mete0rfish mete0rfish commented Jul 2, 2024

한주간 수고 많으셨습니다 👍
이번 주 미션은 구현하는데 많은 시간을 사용했네요.
힘든 미션이었던 만큼 남는 것도 많은 시간이었던것 같습니다!

JPA 커밋 보기

고민한 부분

  1. 5단계에서 초기화 쿼리가 주어집니다.
초기값 설정을 위한 쿼리를 수정해야 합니다.
INSERT INTO reservation (member_id, name, date, time_id, theme_id)
VALUES (1, '', '2024-03-01', 1, 1),
       (1, '', '2024-03-01', 2, 2),
       (1, '', '2024-03-01', 3, 3);

INSERT INTO reservation (name, date, time_id, theme_id)
VALUES ('브라운', '2024-03-01', 1, 2);

이 초기화 쿼리는 name과 member_id가 없습니다.
그리고 5단계 미션 아래에 조건이 주어집니다.

- 관리자가 어드민 화면에서 예약을 생성하는 경우 name 값을 string으로 전달합니다.
- 사용자가 예약 화면에서 예약으 생성하는 경우 로그인 정보를 이용하여 Member의 ID를 Reservation에 저장하도록 합니다.

해당 초기화 쿼리도 이 조건에 성립하도록 하는 방법이 있는지 조사했지만 찾지 못한것 같네요😭

2. JpaRepository에서 제공하는 기본 메서드 (findBy 등)은 기본적으로 Optional을 반환하더라구요. Optional을 사용하게 되면 NullPointerException 대신 NoSuchElementException가 발생하고, 여러 새로운 에러 및 가독성 저하의 문제가 존재합니다. 따라서, 목적없는 Optional을 예방했습니다.
오늘 피드백으로 추가적으로 공부해봐야겠네요!

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.

1 participant