From 1f9c4ee97fc224adfa44977a41e5c4c75612abe6 Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Tue, 15 Oct 2024 01:20:31 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[chore]=20:=20=EC=BF=BC=EB=A6=AC=20DSL=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=EC=9D=84=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index 05f9835..84b85eb 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,11 @@ dependencies { // DB implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.mysql:mysql-connector-j' + // Query DSL + implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta" + annotationProcessor "jakarta.annotation:jakarta.annotation-api" + annotationProcessor "jakarta.persistence:jakarta.persistence-api" // Redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' // Security @@ -49,3 +54,5 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +def querydslDir = "src/main/generated" \ No newline at end of file From 7ae0329144307bd4283876ec62b22110b85783a4 Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Tue, 15 Oct 2024 01:20:42 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[chore]=20:=20=EC=BF=BC=EB=A6=AC=20DSL=20?= =?UTF-8?q?=EB=B9=88=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onetime/global/config/QueryDslConfig.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/side/onetime/global/config/QueryDslConfig.java diff --git a/src/main/java/side/onetime/global/config/QueryDslConfig.java b/src/main/java/side/onetime/global/config/QueryDslConfig.java new file mode 100644 index 0000000..dd8e648 --- /dev/null +++ b/src/main/java/side/onetime/global/config/QueryDslConfig.java @@ -0,0 +1,18 @@ +package side.onetime.global.config; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class QueryDslConfig { + @PersistenceContext + private EntityManager entityManager; + + @Bean + public JPAQueryFactory jpaQueryFactory() { + return new JPAQueryFactory(entityManager); + } +} \ No newline at end of file From bcb7ab3beb6207ab6ecd0ae67a78b564503a139f Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Tue, 15 Oct 2024 01:21:15 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[feat]=20:=20=EC=BF=BC=EB=A6=AC=20DSL=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EC=B6=94=EA=B0=80=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/EventRepositoryCustom.java | 7 ++++ .../custom/EventRepositoryImpl.java | 40 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/side/onetime/repository/custom/EventRepositoryCustom.java create mode 100644 src/main/java/side/onetime/repository/custom/EventRepositoryImpl.java diff --git a/src/main/java/side/onetime/repository/custom/EventRepositoryCustom.java b/src/main/java/side/onetime/repository/custom/EventRepositoryCustom.java new file mode 100644 index 0000000..fac70a2 --- /dev/null +++ b/src/main/java/side/onetime/repository/custom/EventRepositoryCustom.java @@ -0,0 +1,7 @@ +package side.onetime.repository.custom; + +import side.onetime.domain.Event; + +public interface EventRepositoryCustom { + void deleteUserEvent(Event event); +} \ No newline at end of file diff --git a/src/main/java/side/onetime/repository/custom/EventRepositoryImpl.java b/src/main/java/side/onetime/repository/custom/EventRepositoryImpl.java new file mode 100644 index 0000000..e5b0803 --- /dev/null +++ b/src/main/java/side/onetime/repository/custom/EventRepositoryImpl.java @@ -0,0 +1,40 @@ +package side.onetime.repository.custom; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import lombok.RequiredArgsConstructor; +import side.onetime.domain.Event; + +import static side.onetime.domain.QEvent.event; +import static side.onetime.domain.QEventParticipation.eventParticipation; +import static side.onetime.domain.QMember.member; +import static side.onetime.domain.QSchedule.schedule; +import static side.onetime.domain.QSelection.selection; + +@RequiredArgsConstructor +public class EventRepositoryImpl implements EventRepositoryCustom { + + private final JPAQueryFactory queryFactory; + + @Override + public void deleteUserEvent(Event e) { + queryFactory.delete(selection) + .where(selection.schedule.event.eq(e)) + .execute(); + + queryFactory.delete(eventParticipation) + .where(eventParticipation.event.eq(e)) + .execute(); + + queryFactory.delete(schedule) + .where(schedule.event.eq(e)) + .execute(); + + queryFactory.delete(member) + .where(member.event.eq(e)) + .execute(); + + queryFactory.delete(event) + .where(event.eq(e)) + .execute(); + } +} \ No newline at end of file From 8c18a84f894e8e75b6788fd788ddf326e536fe19 Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Tue, 15 Oct 2024 01:21:32 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[refactor]=20:=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EA=B0=80=20=EC=83=9D=EC=84=B1=ED=95=9C=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=82=AD=EC=A0=9C=20=EC=8B=9C=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=20DSL=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/side/onetime/repository/EventRepository.java | 3 ++- src/main/java/side/onetime/service/EventService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/side/onetime/repository/EventRepository.java b/src/main/java/side/onetime/repository/EventRepository.java index 42e5097..f85dafa 100644 --- a/src/main/java/side/onetime/repository/EventRepository.java +++ b/src/main/java/side/onetime/repository/EventRepository.java @@ -2,11 +2,12 @@ import org.springframework.data.jpa.repository.JpaRepository; import side.onetime.domain.Event; +import side.onetime.repository.custom.EventRepositoryCustom; import java.util.Optional; import java.util.UUID; -public interface EventRepository extends JpaRepository { +public interface EventRepository extends JpaRepository, EventRepositoryCustom { Optional findByEventId(UUID eventId); boolean existsByEventId(UUID eventId); } \ No newline at end of file diff --git a/src/main/java/side/onetime/service/EventService.java b/src/main/java/side/onetime/service/EventService.java index 66baf90..2ebb2ba 100644 --- a/src/main/java/side/onetime/service/EventService.java +++ b/src/main/java/side/onetime/service/EventService.java @@ -294,6 +294,6 @@ public void removeUserCreatedEvent(String authorizationHeader, String eventId) { throw new EventParticipationException(EventParticipationErrorResult._IS_NOT_USERS_CREATED_EVENT_PARTICIPATION); } - eventRepository.delete(event); + eventRepository.deleteUserEvent(event); } } \ No newline at end of file From 7b40a4d2ac07e9fc39c7539dfa2c8e8d9032c3ac Mon Sep 17 00:00:00 2001 From: bbbang105 <2018111366@dgu.ac.kr> Date: Tue, 15 Oct 2024 01:35:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[refactor]=20:=20=EB=B0=B0=EC=B9=98=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=A6=88=EB=A5=BC=20=EC=A0=9C=EA=B1=B0?= =?UTF-8?q?=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/side/onetime/domain/Event.java | 3 --- src/main/java/side/onetime/domain/Member.java | 1 - src/main/java/side/onetime/domain/Schedule.java | 1 - src/main/java/side/onetime/domain/User.java | 2 -- 4 files changed, 7 deletions(-) diff --git a/src/main/java/side/onetime/domain/Event.java b/src/main/java/side/onetime/domain/Event.java index 0881b8e..b14ed97 100644 --- a/src/main/java/side/onetime/domain/Event.java +++ b/src/main/java/side/onetime/domain/Event.java @@ -39,15 +39,12 @@ public class Event extends BaseEntity { private Category category; @OneToMany(mappedBy = "event",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List members; @OneToMany(mappedBy = "event",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List schedules; @OneToMany(mappedBy = "event",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List eventParticipations; @Builder diff --git a/src/main/java/side/onetime/domain/Member.java b/src/main/java/side/onetime/domain/Member.java index 0baabb3..667ac21 100644 --- a/src/main/java/side/onetime/domain/Member.java +++ b/src/main/java/side/onetime/domain/Member.java @@ -35,7 +35,6 @@ public class Member extends BaseEntity { private String pin; @OneToMany(mappedBy = "member", cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List selections; @Builder diff --git a/src/main/java/side/onetime/domain/Schedule.java b/src/main/java/side/onetime/domain/Schedule.java index 7c2abb8..98f0e1a 100644 --- a/src/main/java/side/onetime/domain/Schedule.java +++ b/src/main/java/side/onetime/domain/Schedule.java @@ -35,7 +35,6 @@ public class Schedule extends BaseEntity { private String time; @OneToMany(mappedBy = "schedule",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List selections; @Builder diff --git a/src/main/java/side/onetime/domain/User.java b/src/main/java/side/onetime/domain/User.java index 592ad89..334ccf2 100644 --- a/src/main/java/side/onetime/domain/User.java +++ b/src/main/java/side/onetime/domain/User.java @@ -36,11 +36,9 @@ public class User extends BaseEntity { private String providerId; @OneToMany(mappedBy = "user",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List selections; @OneToMany(mappedBy = "user",cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @BatchSize(size = 100) private List eventParticipations; @Builder