-
Notifications
You must be signed in to change notification settings - Fork 0
feat : [JPA 활용 미션 ] 5주차 과제 #5
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
Conversation
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; //pk | ||
| private Long memberId; //pk |
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.
private Long id; -> 이렇게 해도 member_id로 컬럼 이름 저장됩니다.
private Long memberId => 이렇게 하면 CammelCase -> snake_case로 자동 변환돼서 member_id로 저장됩니다.
∴ 그냥 id로 저장해도 된다~
| //2 id 로 멤버 테이블 조회 | ||
| //마이 페이지 화면 쿼리 | ||
| //(메서드 생성 방식 권장) | ||
| 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.
JpaRepository에 기본 내장되어 있습니다.
| JOIN FETCH r.subRegion sr | ||
| WHERE r.id = :regionId | ||
| """, | ||
| countQuery = "SELECT count(m) FROM Mission m JOIN m.store s WHERE s.region.id = :regionId") |
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.
countQuery -> 이게 뭔가 해서 알아봤는데, fetchJoin + Page 하면 CountQuery를 정상적으로 만들지 못한다는걸 배웠네요. 굿굿
| show-sql: true # | ||
| hibernate: | ||
| ddl-auto: create # | ||
| ddl-auto: create-drop # |
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주차 : JPA 활용 미션