Skip to content

Commit

Permalink
refactor(repository): @param 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kyum-q committed Oct 15, 2024
1 parent 9e1d6a2 commit e49502a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ public interface TemplateTagJpaRepository extends TemplateTagRepository, JpaRepo
JOIN TemplateTag tt ON t.id = tt.id.tagId
WHERE tt.template = :template
""")
List<Tag> findAllTagsByTemplate(Template template);
List<Tag> findAllTagsByTemplate(@Param("template") Template template);

@Query("""
SELECT tt, t
FROM TemplateTag tt
JOIN FETCH tt.tag t
WHERE tt.id.templateId = :templateId
""")
List<TemplateTag> findAllByTemplateId(Long templateId);
List<TemplateTag> findAllByTemplateId(@Param("templateId") Long templateId);

@Query("""
SELECT tt, t
FROM TemplateTag tt
JOIN FETCH tt.tag t
WHERE tt.id.templateId in :templateIds
""")
List<TemplateTag> findAllByTemplateIdsIn(List<Long> templateIds);
List<TemplateTag> findAllByTemplateIdsIn(@Param("templateIds") List<Long> templateIds);

@Query("""
SELECT DISTINCT t
Expand All @@ -49,7 +49,7 @@ WHERE tt.id.templateId IN (
)
)
""")
List<Tag> findAllTagDistinctByMemberId(Long memberId);
List<Tag> findAllTagDistinctByMemberId(@Param("memberId") Long memberId);

@Modifying(clearAutomatically = true)
@Query("DELETE FROM TemplateTag t WHERE t.template.id in :templateIds")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Long> templateIds);
void deleteAllByTemplateIds(@Param("templateIds") List<Long> templateIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,20 +29,20 @@ default Thumbnail fetchByTemplate(Template template) {
join fetch t.sourceCode sc
WHERE t.template = :template
""")
Optional<Thumbnail> findByTemplate(Template template);
Optional<Thumbnail> findByTemplate(@Param("template") Template template);


@Modifying(clearAutomatically = true)
@Query("DELETE FROM Thumbnail t WHERE t.template.id in :templateIds")
void deleteAllByTemplateIds(List<Long> templateIds);
void deleteAllByTemplateIds(@Param("templateIds") List<Long> templateIds);

@Query("""
SELECT t, sc
FROM Thumbnail t
join fetch t.sourceCode sc
WHERE t.template.id IN :templateIds
""")
List<Thumbnail> findAllByTemplateIn(List<Long> templateIds);
List<Thumbnail> findAllByTemplateIn(@Param("templateIds") List<Long> templateIds);

void deleteByTemplateId(Long id);

Expand Down

0 comments on commit e49502a

Please sign in to comment.