Skip to content

Commit 4e94f7c

Browse files
committed
cria consulta (query) ao BD que atualiza a posição de um jogos dentro de uma lista específica
1 parent 88f98a5 commit 4e94f7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

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

33
import org.springframework.data.jpa.repository.JpaRepository;
4+
import org.springframework.data.jpa.repository.Modifying;
5+
import org.springframework.data.jpa.repository.Query;
46
import com.gabriel_torelo.game_list.entities.GameList;
57

68
public interface GameListRepository extends JpaRepository<GameList, Long> {
79

10+
@Modifying
11+
@Query(nativeQuery = true, value = """
12+
UPDATE tb_belonging
13+
SET position = :newIndex
14+
WHERE list_id = :listID
15+
AND game_id = :gameID
16+
""")
17+
void moveGameInList(Long listID, Long gameID, Integer newIndex);
818
}

0 commit comments

Comments
 (0)