From e49502a6a4d91fa7026a1ef32065a507272e92d7 Mon Sep 17 00:00:00 2001 From: kyum-q <109158497+kyum-q@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:53:14 +0900 Subject: [PATCH] =?UTF-8?q?refactor(repository):=20@Param=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codezap/tag/repository/TemplateTagJpaRepository.java | 8 ++++---- .../template/repository/SourceCodeJpaRepository.java | 3 ++- .../template/repository/ThumbnailJpaRepository.java | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/codezap/tag/repository/TemplateTagJpaRepository.java b/backend/src/main/java/codezap/tag/repository/TemplateTagJpaRepository.java index 7a98439c..0fb949b8 100644 --- a/backend/src/main/java/codezap/tag/repository/TemplateTagJpaRepository.java +++ b/backend/src/main/java/codezap/tag/repository/TemplateTagJpaRepository.java @@ -20,7 +20,7 @@ public interface TemplateTagJpaRepository extends TemplateTagRepository, JpaRepo JOIN TemplateTag tt ON t.id = tt.id.tagId WHERE tt.template = :template """) - List findAllTagsByTemplate(Template template); + List findAllTagsByTemplate(@Param("template") Template template); @Query(""" SELECT tt, t @@ -28,7 +28,7 @@ public interface TemplateTagJpaRepository extends TemplateTagRepository, JpaRepo JOIN FETCH tt.tag t WHERE tt.id.templateId = :templateId """) - List findAllByTemplateId(Long templateId); + List findAllByTemplateId(@Param("templateId") Long templateId); @Query(""" SELECT tt, t @@ -36,7 +36,7 @@ public interface TemplateTagJpaRepository extends TemplateTagRepository, JpaRepo JOIN FETCH tt.tag t WHERE tt.id.templateId in :templateIds """) - List findAllByTemplateIdsIn(List templateIds); + List findAllByTemplateIdsIn(@Param("templateIds") List templateIds); @Query(""" SELECT DISTINCT t @@ -49,7 +49,7 @@ WHERE tt.id.templateId IN ( ) ) """) - List findAllTagDistinctByMemberId(Long memberId); + List findAllTagDistinctByMemberId(@Param("memberId") Long memberId); @Modifying(clearAutomatically = true) @Query("DELETE FROM TemplateTag t WHERE t.template.id in :templateIds") diff --git a/backend/src/main/java/codezap/template/repository/SourceCodeJpaRepository.java b/backend/src/main/java/codezap/template/repository/SourceCodeJpaRepository.java index 1b59a986..bb9e5833 100644 --- a/backend/src/main/java/codezap/template/repository/SourceCodeJpaRepository.java +++ b/backend/src/main/java/codezap/template/repository/SourceCodeJpaRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import codezap.global.exception.CodeZapException; import codezap.global.exception.ErrorCode; @@ -37,5 +38,5 @@ default SourceCode fetchByTemplateAndOrdinal(Template template, int ordinal) { @Modifying(clearAutomatically = true) @Query("DELETE FROM SourceCode s WHERE s.template.id in :templateIds") - void deleteAllByTemplateIds(List templateIds); + void deleteAllByTemplateIds(@Param("templateIds") List templateIds); } diff --git a/backend/src/main/java/codezap/template/repository/ThumbnailJpaRepository.java b/backend/src/main/java/codezap/template/repository/ThumbnailJpaRepository.java index c88a7c0b..e0bd5e14 100644 --- a/backend/src/main/java/codezap/template/repository/ThumbnailJpaRepository.java +++ b/backend/src/main/java/codezap/template/repository/ThumbnailJpaRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import codezap.global.exception.CodeZapException; import codezap.global.exception.ErrorCode; @@ -28,12 +29,12 @@ default Thumbnail fetchByTemplate(Template template) { join fetch t.sourceCode sc WHERE t.template = :template """) - Optional findByTemplate(Template template); + Optional findByTemplate(@Param("template") Template template); @Modifying(clearAutomatically = true) @Query("DELETE FROM Thumbnail t WHERE t.template.id in :templateIds") - void deleteAllByTemplateIds(List templateIds); + void deleteAllByTemplateIds(@Param("templateIds") List templateIds); @Query(""" SELECT t, sc @@ -41,7 +42,7 @@ default Thumbnail fetchByTemplate(Template template) { join fetch t.sourceCode sc WHERE t.template.id IN :templateIds """) - List findAllByTemplateIn(List templateIds); + List findAllByTemplateIn(@Param("templateIds") List templateIds); void deleteByTemplateId(Long id);