From edbf5f4bd01f78f02dc1aae2aa98b36fabae433d Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 24 Oct 2023 20:59:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FIX]=20Querydsl=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0=20?= =?UTF-8?q?#113?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/parentchild/dao/ParentchildDao.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java index d0d47ab5..1fb5cd1d 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java @@ -41,13 +41,25 @@ public Optional findByUserId(Long userId) { public Optional findMatchUserByUserId(Long userId) { + /*QUser user = QUser.user; // 기존 user 엔티티에 대한 Querydsl 패스 + + return Optional.ofNullable(queryFactory + .selectFrom(user) + .where(user.id.eq(userId) + .and(user.id.ne(user.id))) // 같은 엔티티는 제외하고 다른 유저를 조회 + .fetchOne());*/ + QUser user = QUser.user; QUser uc = new QUser("uc"); return Optional.ofNullable(queryFactory .select(user) .from(user) - .join(uc).on(uc.parentChild.eq(user.parentChild)) - .where(uc.id.eq(userId).and(uc.id.ne(user.id))) + .where(user.id.ne(userId) + .and(user.parentChild.eq( + JPAExpressions.select(uc.parentChild) + .from(uc) + .where(uc.id.eq(userId)) + ))) .fetchOne()); } From 74c90f383b559698764d80ea9b6559e771990ef3 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 24 Oct 2023 21:02:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[CHORE]=20=EC=98=A4=EB=A5=98=EA=B0=80=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=ED=95=9C=20=EC=BF=BC=EB=A6=AC=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/domain/parentchild/dao/ParentchildDao.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java index 1fb5cd1d..535ee387 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/parentchild/dao/ParentchildDao.java @@ -41,13 +41,6 @@ public Optional findByUserId(Long userId) { public Optional findMatchUserByUserId(Long userId) { - /*QUser user = QUser.user; // 기존 user 엔티티에 대한 Querydsl 패스 - - return Optional.ofNullable(queryFactory - .selectFrom(user) - .where(user.id.eq(userId) - .and(user.id.ne(user.id))) // 같은 엔티티는 제외하고 다른 유저를 조회 - .fetchOne());*/ QUser user = QUser.user; QUser uc = new QUser("uc");