Skip to content

Commit

Permalink
fix: 태그 삭제 쿼리 메서드에 @Modifying을 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hseong3243 committed Apr 11, 2024
1 parent 3754776 commit 25193aa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import java.util.List;
import java.util.Optional;
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;

public interface TagJpaRepository extends JpaRepository<TagEntity, Long> {

@Modifying
@Query("delete from HubTagEntity t where t.hubId=:hubId")
long deleteByHubId(@Param("hubId") Long hubId);
void deleteByHubId(@Param("hubId") Long hubId);

@Query("select t from HubTagEntity t"
+ " where t.hubId=:hubId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public List<Tag> saveAll(List<HubTag> tags) {
}

@Override
public long deleteHubTags(Hub hub) {
return tagJpaRepository.deleteByHubId(hub.getHubId());
public void deleteHubTags(Hub hub) {
tagJpaRepository.deleteByHubId(hub.getHubId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface TagRepository {

List<Tag> saveAll(List<HubTag> tags);

long deleteHubTags(Hub hub);
void deleteHubTags(Hub hub);

Optional<Tag> findLatestTagByHub(Hub hub);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ public List<Tag> saveAll(List<HubTag> hubTags) {
}

@Override
public long deleteHubTags(Hub hub) {
int size = memory.size();
public void deleteHubTags(Hub hub) {
memory.clear();
return size;
}

@Override
Expand Down

0 comments on commit 25193aa

Please sign in to comment.