-
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
…tor-type-query [BE-REFACTOR] PokemonType 쿼리 개선
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...gue/src/main/java/com/pokerogue/helper/type/repository/PokemonTypeMatchingRepository.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,7 +1,19 @@ | ||
package com.pokerogue.helper.type.repository; | ||
|
||
import com.pokerogue.helper.type.domain.PokemonTypeMatching; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.lang.NonNull; | ||
|
||
public interface PokemonTypeMatchingRepository extends JpaRepository<PokemonTypeMatching, Long> { | ||
|
||
@Override | ||
@NonNull | ||
@Query(""" | ||
select ptm from PokemonTypeMatching ptm | ||
join fetch ptm.toType tt | ||
join fetch ptm.fromType ft | ||
""") | ||
List<PokemonTypeMatching> findAll(); | ||
} |
31 changes: 31 additions & 0 deletions
31
...src/test/java/com/pokerogue/helper/type/repository/PokemonTypeMatchingRepositoryTest.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 com.pokerogue.helper.type.repository; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.pokerogue.environment.repository.RepositoryTest; | ||
import com.pokerogue.helper.type.domain.PokemonTypeMatching; | ||
import java.util.List; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
class PokemonTypeMatchingRepositoryTest extends RepositoryTest { | ||
|
||
@Autowired | ||
private PokemonTypeMatchingRepository pokemonTypeMatchingRepository; | ||
|
||
|
||
/* | ||
PR: [BE-REFACTOR] Pokemon 쿼리 개선 #133 | ||
위 PR이 먼저 머지되어야 실행 가능한 테스트라서 주석 처리함. | ||
*/ | ||
// @Test | ||
// @DisplayName("포켓몬의 모든 타입 매칭 정보를 조회한다.") | ||
// void findAll() { | ||
// List<PokemonTypeMatching> pokemonTypeMatchings = pokemonTypeMatchingRepository.findAll(); | ||
// | ||
// Assertions.assertThat(pokemonTypeMatchings).isNotEmpty(); | ||
// } | ||
|
||
} |