diff --git a/backend/src/main/java/com/example/todoapp/repository/ToBuysRepository.java b/backend/src/main/java/com/example/todoapp/repository/ToBuysRepository.java index d9b6861..0778f5f 100644 --- a/backend/src/main/java/com/example/todoapp/repository/ToBuysRepository.java +++ b/backend/src/main/java/com/example/todoapp/repository/ToBuysRepository.java @@ -40,13 +40,13 @@ public interface ToBuysRepository extends JpaRepository { ToBuys findByTobuyId(Long tobuyId); /** - * 指定されたユーザーIDに基づいて「買うもの」リストを取得する + * 指定されたユーザーIDに基づいて「買うもの」リストを取得する_(tobuyIdの順番) * * @param userId ユーザーID * @return 「買うもの」リスト */ - @Query("SELECT t FROM ToBuys t WHERE t.user.id = ?1") - List findByUserIdOrderByTobuyIdAsc(Long userId); + @Query("SELECT t FROM ToBuys t WHERE t.user.id = :userId ORDER BY t.tobuyId ASC") + List findByUserIdOrderByTobuyIdAsc(@Param("userId") Long userId); /** * 指定された「買うもの」IDに基づいて「買うもの」リストを削除