Skip to content

Commit

Permalink
fix : [#5] 동시성 테스트 수정
Browse files Browse the repository at this point in the history
- `@Lock`, `@Transactional` 사용
  • Loading branch information
kjh418 committed Oct 3, 2024
1 parent 42ff586 commit e93af13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import hhplus.lecture.infrastructure.repository.LectureItemRepository;
import hhplus.lecture.infrastructure.repository.RegistrationRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
@Transactional
public class RegistrationService {

private final LectureService lectureService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package hhplus.lecture.infrastructure.repository;

import hhplus.lecture.infrastructure.persistence.LectureItemEntity;
import jakarta.persistence.LockModeType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;

import java.time.LocalDate;
import java.util.List;

public interface LectureItemRepository extends JpaRepository<LectureItemEntity, String> {

// 특강 정보
@Lock(LockModeType.PESSIMISTIC_WRITE)
LectureItemEntity findByLectureItemCode(String lectureItemCode);

List<LectureItemEntity> findAllByLectureDate(LocalDate targetDate);
Expand Down

0 comments on commit e93af13

Please sign in to comment.