diff --git a/backend/src/main/java/com/example/todoapp/repository/RecipeStuffsRepository.java b/backend/src/main/java/com/example/todoapp/repository/RecipeStuffsRepository.java index 4c0609d..4ac6eaa 100644 --- a/backend/src/main/java/com/example/todoapp/repository/RecipeStuffsRepository.java +++ b/backend/src/main/java/com/example/todoapp/repository/RecipeStuffsRepository.java @@ -7,6 +7,13 @@ import org.springframework.data.jpa.repository.JpaRepository; import com.example.todoapp.model.RecipeStuffs; +import jakarta.transaction.Transactional; + +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + /** * レシピ食材関連データのリポジトリインターフェース *

@@ -31,4 +38,5 @@ public interface RecipeStuffsRepository extends JpaRepository findByRecipesRecipeIdAndStuffStuffId(Long recipeId, Long stuffId); + } 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に基づいて「買うもの」リストを削除