File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
src/main/java/com/threestar/trainus/domain/lesson/teacher/repository Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 77import org .springframework .data .domain .Page ;
88import org .springframework .data .domain .Pageable ;
99import org .springframework .data .jpa .repository .JpaRepository ;
10+ import org .springframework .data .jpa .repository .Lock ;
1011import org .springframework .data .jpa .repository .Query ;
1112import org .springframework .data .repository .query .Param ;
1213
1314import com .threestar .trainus .domain .lesson .teacher .entity .Category ;
1415import com .threestar .trainus .domain .lesson .teacher .entity .Lesson ;
1516import com .threestar .trainus .domain .lesson .teacher .entity .LessonStatus ;
1617
18+ import jakarta .persistence .LockModeType ;
19+
1720public 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}
You can’t perform that action at this time.
0 commit comments