File tree Expand file tree Collapse file tree
src/main/java/ceos/backend/domain/application Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,8 +49,9 @@ public void sendSlackUnableReasonMessage(
4949 }
5050
5151 public Application getApplicationById (Long id ) {
52+
5253 return applicationRepository
53- .findById (id )
54+ .findByIdWithPessimisticLock (id )
5455 .orElseThrow (
5556 () -> {
5657 throw ApplicantNotFound .EXCEPTION ;
Original file line number Diff line number Diff line change 55import ceos .backend .domain .application .domain .Pass ;
66import ceos .backend .global .common .entity .Part ;
77import java .util .Optional ;
8+
9+ import jakarta .persistence .LockModeType ;
810import org .springframework .data .domain .Page ;
911import org .springframework .data .domain .PageRequest ;
1012import org .springframework .data .jpa .repository .JpaRepository ;
13+ import org .springframework .data .jpa .repository .Lock ;
1114import org .springframework .data .jpa .repository .Query ;
1215import org .springframework .data .repository .query .Param ;
1316
@@ -63,4 +66,10 @@ Page<Application> findAllByPartAndDocumentPassAndFinalPass(
6366 @ Param ("convertedDocPass" ) Pass convertedDocPass ,
6467 @ Param ("convertedFinalPass" ) Pass convertedFinalPass ,
6568 PageRequest pageRequest );
69+
70+
71+ @ Lock (LockModeType .PESSIMISTIC_WRITE )
72+ @ Query ("select a from Application a where a.id = :id" )
73+ Optional <Application > findByIdWithPessimisticLock (@ Param ("id" ) Long id );
74+
6675}
You can’t perform that action at this time.
0 commit comments