Skip to content

Conversation

@minmin02
Copy link
Contributor

5주차 : JPA 활용 미션

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; //pk
private Long memberId; //pk

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);

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")

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 #

Choose a reason for hiding this comment

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

실제로 프젝할 때는 이걸루 두면 안돼요..ㅎ

@minmin02 minmin02 merged commit dd2d404 into develop Nov 2, 2025
1 check passed
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.

3 participants