-
Notifications
You must be signed in to change notification settings - Fork 4
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
카페 이미지 Fetch Join 시 Inner Join 하도록 변경 #468
Conversation
515f684
to
7d5fbde
Compare
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.
연어덕에 전반적으로 코드가 많이 좋아졌네요!
감사합니다!
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embedded; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.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.
감사합니다!
public Cafe(final String name, final String address, final Images images, final Detail detail) { | ||
this(null, name, address, images, detail, 0); | ||
} |
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
@Query(""" | ||
select m | ||
from Member m | ||
left join fetch m.unViewedCafes uvc | ||
left join fetch uvc.cafe | ||
where m.id = :id | ||
SELECT m | ||
FROM Member m | ||
LEFT JOIN FETCH m.unViewedCafes uvc | ||
LEFT JOIN FETCH uvc.cafe | ||
WHERE m.id = :id | ||
""") | ||
Optional<Member> findById(@Param("id") String 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.
흐음. 여기도 inner join 해도 되지 않나요???'
문제가 없는 부분이라 대문자 패치만 하신걸까요??
아 대문자 패치는 감사합니다!3
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.
UnViewedCafe
와 Cafe
는 1:1 not null 관계이기 때문에 inner join이 좋을 것 같아요!
@@ -35,8 +32,6 @@ public enum ErrorCode { | |||
NOT_EXISTED_OAUTH_PROVIDER("O2", "잘못된 Provider Name 입니다."), | |||
NOT_EXISTED_OAUTH_CLIENT("O3", "일치하는 OAuthClient가 존재하지 않습니다."), | |||
|
|||
RANK_OUT_OF_BOUNDS("R1", format("좋아요 개수 랭킹 범위를 벗어나는 요청입니다. 좋아요 랭킹은 %d위까지 가능합니다. 요청의 페이지 확인이 필요합니다.", MAX_RANK)), | |||
|
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.
랭킹 범위 수정 감사합니다~
@@ -22,3 +22,4 @@ spring.flyway.enabled=true | |||
spring.flyway.baseline-version=20230901153300 | |||
spring.flyway.baseline-on-migrate=true | |||
spring.flyway.out-of-order=true | |||
spring.jpa.properties.hibernate.default_batch_fetch_size=1000 |
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.
굿~ 테스트 쪽을 신경 못 썼네요..
SELECT m | ||
FROM Member m | ||
LEFT JOIN FETCH m.unViewedCafes uvc | ||
JOIN FETCH uvc.cafe |
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.
헉 이 부분 때문에 테스트가 와장창 깨지는 것 같아요!
테스트에서 member를 찾지 못하고 있네요
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.
😹
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.
이렇게 진행될 경우에 uvc가 없는 멤버는 조회되지 않을 것 같네요 ...
음 . . findbyid 메소드 자체를 오버로딩해서 사용해야 될 수도 있겠는데요 ?!
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.
메서드를 따로 분리했습니다
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.
고생하셨어요 연어~
도치 폴로가 이미 좋은 코멘트를 남겨줬었네요!
현재 테스트 코드가 깨지고있는 fetch join 시 inner join에 대해서 같이 이야기하면서 해결하면 좋을 것 같아요! 일단 inner조인 처리를 하려는 이유가 궁금합니다! 또한 코멘트에 남겼듯이 지금과 같은 방식대로 진행하려면 메소드를 오버로딩 해서 처리해도 될 것 같은데 연어의 의견도 궁금하네용
SELECT c | ||
FROM Cafe c | ||
JOIN FETCH c.images.urls | ||
WHERE c.id = :cafeId |
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.
👍
코멘트 달아주신
cafe.images.url 조인할 때 outer join -> inner join으로 변경 (패치 조인 가능)
에서 패치 조인 가능 이라는게 어떤 건가요? outer join -> inner join으로 변경해서 패치조인이 가능해졌다 ?
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.
outer join -> inner join으로 변경해서 패치조인이 가능해졌다 ?
말이 맞습니다!
@@ -22,7 +23,7 @@ public class Detail { | |||
public static final int PHONE_MAX_LENGTH = 20; | |||
|
|||
@ElementCollection(fetch = FetchType.LAZY) |
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.
여기도 images 처럼 fetchtype 생략해도 되겠네요
SELECT m | ||
FROM Member m | ||
LEFT JOIN FETCH m.unViewedCafes uvc | ||
JOIN FETCH uvc.cafe |
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.
😹
response.add(CafeRankResponse.of(++rank, cafe)); | ||
} | ||
|
||
return response; |
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.
RankGenerator를 없애주셨군요 👍
SELECT m | ||
FROM Member m | ||
LEFT JOIN FETCH m.unViewedCafes uvc | ||
JOIN FETCH uvc.cafe |
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.
이렇게 진행될 경우에 uvc가 없는 멤버는 조회되지 않을 것 같네요 ...
음 . . findbyid 메소드 자체를 오버로딩해서 사용해야 될 수도 있겠는데요 ?!
지도 기능 main merge
osiv main merge
…-log 불필요한 `console.log` 삭제
f9bd513
to
8642078
Compare
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.
고생했어요 연어
#️⃣ 연관된 이슈
📝 작업 내용
CafeRankGenerator
제거(Pageable
의offset
사용)