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

[BE] 복잡한 쿼리를 리팩터링한다. #436

Closed
kth990303 opened this issue Sep 14, 2022 · 0 comments · Fixed by #500
Closed

[BE] 복잡한 쿼리를 리팩터링한다. #436

kth990303 opened this issue Sep 14, 2022 · 0 comments · Fixed by #500

Comments

@kth990303
Copy link
Collaborator

기능 상세

  • 아래와 같은 어마어마한 JPQL을 리팩터링하는 것이 최우선 목표이다.
 @Query(value = "select distinct new com.woowacourse.naepyeon.service.dto.WrittenMessageResponseDto"
            + "(m.id, r.id, r.title, t.id, t.name, m.content, m.color, "
            + "case when r.recipient = com.woowacourse.naepyeon.domain.rollingpaper.Recipient.MEMBER then p.nickname "
            + "when r.recipient = com.woowacourse.naepyeon.domain.rollingpaper.Recipient.TEAM then t.name "
            + "else '' end) "
            + "from Message m"
            + ", Rollingpaper r"
            + ", Team t"
            + ", TeamParticipation p "
            + "where m.rollingpaper.id = r.id "
            + "and r.team.id = t.id "
            + "and p.team.id = t.id "
            + "and m.author.id = :authorId "
            + "and (p.member.id = r.member.id or r.member.id is null)")
Page<WrittenMessageResponseDto> findAllByAuthorId(@Param("authorId") final Long authorId,
                                                  final Pageable pageRequest);

queryDSL을 적용(#421) 한 후에 위 쿼리를 리팩터링해보자

  1. Entity를 양방향으로 바꿔서 theta join을 없애고 코드도 간단하게 바꾸자. (논의 필요)
  • Participation을 member에서 가지게 하면 어떨까? 내가 속해있는 모임을 조회할 일이 꽤 있을 듯하다.
  • Participation을 member, team에서 모두 가지게 하고 있는 방법은?
  1. 다른 방법이 있으면 edit 후 추가부탁
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
1 participant