Step3-kakao-tech-campus / Team3_BE

[카테캠 1기] 번개 지향 볼링 모집 커뮤니티 "번개볼링"의 백엔드 서버입니다.
2 stars 4 forks source link

참여 기록 조회 기준 수정, post 양방향 제거 #68

Closed xcelxlorx closed 11 months ago

xcelxlorx commented 11 months ago

Summary

Description

jpa specification는 검색 조건을 조합해서 검색하기 때문에 applicants를 따로 쿼리를 사용해서 가져오더라도 조건에서 post-applicants를 접근하기 어렵다고 생각해서 서브쿼리를 사용했습니다. 더 좋은 방법이 있다면 말씀해 주세요.

실행되는 쿼리 select p1_0.id, p1_0.content, p1_0.created_at, d1_0.id, c1_0.id, c2_0.id, c2_0.name, c1_0.name, d1_0.name, d1_0.statutory_code, p1_0.due_time, p1_0.edited_at, p1_0.is_close, p1_0.start_time, p1_0.title, p1_0.user_id, p1_0.view_count from post_tb p1_0 left join district_tb d1_0 on d1_0.id=p1_0.district_id left join country_tb c1_0 on c1_0.id=d1_0.country_id left join city_tb c2_0 on c2_0.id=c1_0.city_id where ( p1_0.user_id=? or p1_0.id in ((select a1_0.post_id from applicant_tb a1_0 join post_tb p2_0 on p2_0.id=a1_0.post_id where a1_0.status and a1_0.user_id=?)) and p1_0.user_id!=? ) and 1=1 and 1=1 and p1_0.start_time>=? order by p1_0.id desc offset ? rows fetch first ? rows only

Related Issue

Issue Number: close #65 Issue Number: #66