Skip to content

Commit 7d70331

Browse files
committed
fix:conflict수정
1 parent 7657354 commit 7d70331

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/com/threestar/trainus/domain/lesson/teacher/repository/LessonRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import org.springframework.data.domain.Page;
88
import org.springframework.data.domain.Pageable;
99
import org.springframework.data.jpa.repository.JpaRepository;
10+
import org.springframework.data.jpa.repository.Lock;
1011
import org.springframework.data.jpa.repository.Query;
1112
import org.springframework.data.repository.query.Param;
1213

1314
import com.threestar.trainus.domain.lesson.teacher.entity.Category;
1415
import com.threestar.trainus.domain.lesson.teacher.entity.Lesson;
1516
import com.threestar.trainus.domain.lesson.teacher.entity.LessonStatus;
1617

18+
import jakarta.persistence.LockModeType;
19+
1720
public interface LessonRepository extends JpaRepository<Lesson, Long> {
1821
//삭제되지 않은 레슨만 조회
1922
Optional<Lesson> findByIdAndDeletedAtIsNull(Long lessonId);
@@ -107,4 +110,8 @@ WHERE l.status IN (
107110
AND l.deletedAt IS NULL
108111
""")
109112
List<Lesson> findLessonsToComplete(@Param("now") LocalDateTime now);
113+
114+
@Lock(LockModeType.PESSIMISTIC_WRITE) // 비관적 락 적용
115+
@Query("SELECT l FROM Lesson l WHERE l.id = :lessonId")
116+
Optional<Lesson> findByIdWithLock(@Param("lessonId") Long lessonId);
110117
}

0 commit comments

Comments
 (0)