-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 장소 통계 도메인에 대해 낙관적 락 적용 * feat: 퍼사드 계층에서 낙관적 락 재시도 로직 구현 * feat: 낙관적 락을 사용하는 Repository 메서드 분리 * fix: `@Param` 어노테이션 추가 * fix: catch 하는 예외를 OptimisticLockingFailureException 로 구체화 * refactor: 재시도 로직을 사용할 대상 클래스를 PlaceStatistics 에서 PlaceLike 로 변경 * refactor: 낙관적 락에서 비관적 락으로 변경 * test: 동시성 테스트 수정
- Loading branch information
Showing
5 changed files
with
111 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
backend/src/main/java/com/now/naaga/place/repository/PlaceStatisticsRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package com.now.naaga.place.repository; | ||
|
||
import com.now.naaga.place.domain.PlaceStatistics; | ||
import jakarta.persistence.LockModeType; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Lock; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface PlaceStatisticsRepository extends JpaRepository<PlaceStatistics, Long> { | ||
|
||
Optional<PlaceStatistics> findByPlaceId(Long placeId); | ||
Optional<PlaceStatistics> findByPlaceId(final Long placeId); | ||
|
||
@Lock(LockModeType.PESSIMISTIC_WRITE) | ||
@Query("SELECT ps FROM PlaceStatistics ps WHERE ps.place.id = :placeId") | ||
Optional<PlaceStatistics> findByPlaceIdForUpdate(@Param("placeId") final Long placeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters