forked from woowacourse-teams/2024-touroot
-
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.
[Fix] - JPQL 관련 alias ambiguous 예외 발생 (woowacourse-teams#352)
* fix: 중복되는 table alias 변경 * fix: 예외 발생 중인 JPQL을 대체하는 QueryDSL 구현 * fix: 여행기 삭제 및 수정 기능 쿼리 수정
- Loading branch information
Showing
20 changed files
with
182 additions
and
28 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/kr/touroot/travelogue/repository/TraveloguePhotoRepository.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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
package kr.touroot.travelogue.repository; | ||
|
||
import java.util.List; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import kr.touroot.travelogue.domain.TraveloguePhoto; | ||
import kr.touroot.travelogue.domain.TraveloguePlace; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface TraveloguePhotoRepository extends JpaRepository<TraveloguePhoto, Long> { | ||
|
||
List<TraveloguePhoto> findByTraveloguePlace(TraveloguePlace traveloguePlace); | ||
|
||
@Modifying(flushAutomatically = true, clearAutomatically = true) | ||
@Query("UPDATE TraveloguePhoto to SET to.deletedAt = NOW() WHERE to.traveloguePlace.travelogueDay.travelogue = :travelogue") | ||
void deleteAllByTraveloguePlaceTravelogueDayTravelogue(Travelogue travelogue); | ||
} |
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/kr/touroot/travelogue/repository/TraveloguePlaceRepository.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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
package kr.touroot.travelogue.repository; | ||
|
||
import java.util.List; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import kr.touroot.travelogue.domain.TravelogueDay; | ||
import kr.touroot.travelogue.domain.TraveloguePlace; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface TraveloguePlaceRepository extends JpaRepository<TraveloguePlace, Long> { | ||
|
||
List<TraveloguePlace> findByTravelogueDay(TravelogueDay travelogueDay); | ||
|
||
@Modifying(flushAutomatically = true, clearAutomatically = true) | ||
@Query("UPDATE TraveloguePlace tp SET tp.deletedAt = NOW() WHERE tp.travelogueDay.travelogue = :travelogue") | ||
void deleteAllByTravelogueDayTravelogue(Travelogue travelogue); | ||
} |
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
8 changes: 8 additions & 0 deletions
8
...nd/src/main/java/kr/touroot/travelogue/repository/query/TravelogueDayQueryRepository.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,8 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import kr.touroot.travelogue.domain.Travelogue; | ||
|
||
public interface TravelogueDayQueryRepository { | ||
|
||
void deleteAllByTravelogue(Travelogue travelogue); | ||
} |
24 changes: 24 additions & 0 deletions
24
...rc/main/java/kr/touroot/travelogue/repository/query/TravelogueDayQueryRepositoryImpl.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,24 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import static kr.touroot.travelogue.domain.QTravelogueDay.travelogueDay; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.time.LocalDateTime; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TravelogueDayQueryRepositoryImpl implements TravelogueDayQueryRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public void deleteAllByTravelogue(Travelogue travelogue) { | ||
jpaQueryFactory.update(travelogueDay) | ||
.set(travelogueDay.deletedAt, LocalDateTime.now()) | ||
.where(travelogueDay.travelogue.eq(travelogue)) | ||
.execute(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../src/main/java/kr/touroot/travelogue/repository/query/TraveloguePhotoQueryRepository.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,8 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import kr.touroot.travelogue.domain.Travelogue; | ||
|
||
public interface TraveloguePhotoQueryRepository { | ||
|
||
void deleteAllByTravelogue(Travelogue travelogue); | ||
} |
31 changes: 31 additions & 0 deletions
31
.../main/java/kr/touroot/travelogue/repository/query/TraveloguePhotoQueryRepositoryImpl.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,31 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import static kr.touroot.travelogue.domain.QTravelogueDay.travelogueDay; | ||
import static kr.touroot.travelogue.domain.QTraveloguePhoto.traveloguePhoto; | ||
|
||
import com.querydsl.jpa.JPAExpressions; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.time.LocalDateTime; | ||
import kr.touroot.travelogue.domain.QTravelogue; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TraveloguePhotoQueryRepositoryImpl implements TraveloguePhotoQueryRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public void deleteAllByTravelogue(Travelogue travelogue) { | ||
jpaQueryFactory.update(traveloguePhoto) | ||
.set(traveloguePhoto.deletedAt, LocalDateTime.now()) | ||
.where(traveloguePhoto.traveloguePlace.travelogueDay.eq( | ||
JPAExpressions.selectFrom(travelogueDay) | ||
.leftJoin(QTravelogue.travelogue) | ||
.on(QTravelogue.travelogue.eq(travelogue)) | ||
)) | ||
.execute(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../src/main/java/kr/touroot/travelogue/repository/query/TraveloguePlaceQueryRepository.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,8 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import kr.touroot.travelogue.domain.Travelogue; | ||
|
||
public interface TraveloguePlaceQueryRepository { | ||
|
||
void deleteAllByTravelogue(Travelogue travelogue); | ||
} |
24 changes: 24 additions & 0 deletions
24
.../main/java/kr/touroot/travelogue/repository/query/TraveloguePlaceQueryRepositoryImpl.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,24 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import static kr.touroot.travelogue.domain.QTraveloguePlace.traveloguePlace; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.time.LocalDateTime; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TraveloguePlaceQueryRepositoryImpl implements TraveloguePlaceQueryRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public void deleteAllByTravelogue(Travelogue travelogue) { | ||
jpaQueryFactory.update(traveloguePlace) | ||
.set(traveloguePlace.deletedAt, LocalDateTime.now()) | ||
.where(traveloguePlace.travelogueDay.travelogue.eq(travelogue)) | ||
.execute(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nd/src/main/java/kr/touroot/travelogue/repository/query/TravelogueTagQueryRepository.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,8 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import kr.touroot.travelogue.domain.Travelogue; | ||
|
||
public interface TravelogueTagQueryRepository { | ||
|
||
void deleteAllByTravelogue(Travelogue travelogue); | ||
} |
22 changes: 22 additions & 0 deletions
22
...rc/main/java/kr/touroot/travelogue/repository/query/TravelogueTagQueryRepositoryImpl.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,22 @@ | ||
package kr.touroot.travelogue.repository.query; | ||
|
||
import static kr.touroot.travelogue.domain.QTravelogueTag.travelogueTag; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import kr.touroot.travelogue.domain.Travelogue; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TravelogueTagQueryRepositoryImpl implements TravelogueTagQueryRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
@Override | ||
public void deleteAllByTravelogue(Travelogue travelogue) { | ||
jpaQueryFactory.delete(travelogueTag) | ||
.where(travelogueTag.travelogue.eq(travelogue)) | ||
.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
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
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
Oops, something went wrong.