Skip to content

Commit

Permalink
Deploy: 더미데이터 실행 과정 중 initial()과 saveRefreshTokenToRedis() 메서드 실행을 별도…
Browse files Browse the repository at this point in the history
…의 트랜잭션으로 관리 (#113)

deploy: 더미데이터 실행 별도의 트랜잭션에서 수행
  • Loading branch information
GitJIHO authored Oct 26, 2024
1 parent 08bf252 commit d6c6787
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.example.sinitto.sinitto.repository.SinittoBankInfoRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
Expand Down Expand Up @@ -72,13 +73,13 @@ public InitialData(MemberRepository memberRepository, SeniorRepository seniorRep
}

@Override
@Transactional
public void run(String... args) {
initial();
saveRefreshTokenToRedis();
}

private void saveRefreshTokenToRedis() {
@Transactional(propagation = Propagation.REQUIRES_NEW)
protected void saveRefreshTokenToRedis() {
System.out.println("---------------[더미데이터] 멤버별 RefreshToken---------------");
System.out.printf("시니또1 김철수(MemberId : 1)의 refreshToken : %s%n", tokenService.generateRefreshToken("[email protected]"));
System.out.printf("시니또2 김유진(MemberId : 2)의 refreshToken : %s%n", tokenService.generateRefreshToken("[email protected]"));
Expand All @@ -93,7 +94,8 @@ private void saveRefreshTokenToRedis() {
System.out.println("----------------------------------------------------------");
}

private void initial() {
@Transactional
protected void initial() {
//시니또
Member memberSinitto1 = memberRepository.save(new Member("김철수", "01012345678", "[email protected]", true));
sinittoBankInfoRepository.save(new SinittoBankInfo("신한은행", "123-23-444-422", memberSinitto1));
Expand Down

0 comments on commit d6c6787

Please sign in to comment.