-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[feat] : 쿼리 DSL 기능을 추가한다
- Loading branch information
Showing
10 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/side/onetime/global/config/QueryDslConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/side/onetime/repository/custom/EventRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package side.onetime.repository.custom; | ||
|
||
import side.onetime.domain.Event; | ||
|
||
public interface EventRepositoryCustom { | ||
void deleteUserEvent(Event event); | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/side/onetime/repository/custom/EventRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters