Skip to content

Commit 7fadf19

Browse files
Merge pull request #20 from GabrielTorelo/feat/gameRepository
feat/gameRepository#002 - OK
2 parents e7da4a3 + 23a2061 commit 7fadf19

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
package com.gabriel_torelo.game_list.repositories;
22

3+
import java.util.List;
34
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Query;
46
import com.gabriel_torelo.game_list.entities.Game;
7+
import com.gabriel_torelo.game_list.projections.GameMinProjection;
58

69
public interface GameRepository extends JpaRepository<Game, Long> {
710

11+
@Query(nativeQuery = true, value = """
12+
SELECT tb_game.id, tb_game.title, tb_game.score, tb_game.img_url AS imgUrl, tb_belonging.position
13+
FROM tb_game
14+
INNER JOIN tb_belonging ON tb_game.id = tb_belonging.game_id
15+
WHERE tb_belonging.list_id = :listId
16+
ORDER BY tb_belonging.position
17+
""")
18+
List<GameMinProjection> readListID(Long listId);
819
}

0 commit comments

Comments
 (0)