From dec5cee77d8c1f36f9ab93f4de325b7e8a284704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=AA=85=EB=8D=95?= <68066437+Profile-exe@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:17:15 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=B1=84=ED=8C=85=20=EB=82=B4=EC=97=AD?= =?UTF-8?q?=EB=A7=8C=ED=81=BC=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=9D=B4=20=EB=B0=98=ED=99=98=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolve #108 --- .../repository/MatchingRepositoryCustomImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/econo/buddybridge/matching/repository/MatchingRepositoryCustomImpl.java b/src/main/java/econo/buddybridge/matching/repository/MatchingRepositoryCustomImpl.java index bbdd058..8eefa92 100644 --- a/src/main/java/econo/buddybridge/matching/repository/MatchingRepositoryCustomImpl.java +++ b/src/main/java/econo/buddybridge/matching/repository/MatchingRepositoryCustomImpl.java @@ -6,7 +6,9 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.CaseBuilder; +import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; +import econo.buddybridge.chat.chatmessage.entity.QChatMessage; import econo.buddybridge.matching.dto.MatchingCustomPage; import econo.buddybridge.matching.dto.MatchingResDto; import econo.buddybridge.matching.dto.QMatchingResDto; @@ -28,6 +30,8 @@ public class MatchingRepositoryCustomImpl implements MatchingRepositoryCustom { public MatchingCustomPage findMatchings(Long memberId, Integer size, LocalDateTime cursor, MatchingStatus matchingStatus, Pageable page) { int pageSize = page.getPageSize(); + QChatMessage subChatMessage = new QChatMessage("subChatMessage"); + List matchingResDtos = queryFactory .select(new QMatchingResDto( matching.id, @@ -44,7 +48,11 @@ public MatchingCustomPage findMatchings(Long memberId, Integer size, LocalDateTi ) )) .from(matching) - .leftJoin(chatMessage).on(chatMessage.matching.id.eq(matching.id)) + .leftJoin(chatMessage).on(chatMessage.matching.eq(matching) + .and(chatMessage.id.eq(JPAExpressions + .select(subChatMessage.id.max()) + .from(subChatMessage) + .where(subChatMessage.matching.eq(matching))))) .leftJoin(member).on( member.id.eq( new CaseBuilder()