-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: List로 가지던 연관 관계 Set으로 변경, Repository 메서드 네이밍 변경
- Loading branch information
Showing
7 changed files
with
53 additions
and
60 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordStepDefinitions.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
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
24 changes: 21 additions & 3 deletions
24
backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.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,20 +1,38 @@ | ||
package wooteco.prolog.roadmap.domain.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.EntityGraph; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import wooteco.prolog.roadmap.domain.Keyword; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.FETCH; | ||
|
||
public interface KeywordRepository extends JpaRepository<Keyword, Long> { | ||
|
||
@EntityGraph(attributePaths = "recommendedPosts", type = FETCH) | ||
Optional<Keyword> findById(final long id); | ||
|
||
@EntityGraph(attributePaths = "recommendedPosts", type = FETCH) | ||
List<Keyword> findAll(); | ||
|
||
@Query("SELECT k FROM Keyword k " | ||
+ "LEFT JOIN FETCH k.children c " | ||
+ "LEFT JOIN FETCH k.recommendedPosts " | ||
+ "LEFT JOIN FETCH k.parent p " | ||
+ "LEFT JOIN FETCH c.children lc WHERE k.id = :keywordId ORDER BY k.seq") | ||
Keyword findFetchById(@Param("keywordId") Long keywordId); | ||
+ "LEFT JOIN FETCH p.recommendedPosts " | ||
+ "LEFT JOIN FETCH c.recommendedPosts " | ||
+ "LEFT JOIN FETCH c.children lc " | ||
+ "LEFT JOIN FETCH lc.recommendedPosts " | ||
+ "LEFT JOIN FETCH lc.children " | ||
+ "WHERE k.id = :keywordId ORDER BY k.seq") | ||
Keyword findFetchByIdOrderBySeq(@Param("keywordId") Long keywordId); | ||
|
||
@Query("SELECT k FROM Keyword k " | ||
+ "LEFT JOIN FETCH k.recommendedPosts " | ||
+ "WHERE k.sessionId = :sessionId AND k.parent IS NULL") | ||
List<Keyword> findBySessionIdAndParentIsNull(@Param("sessionId") Long sessionId); | ||
} |
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