woowacourse-teams / 2022-pickpick

🐹 사라지는 Slack 메시지, 우리가 주워줄게!
https://jupjup.site
72 stars 6 forks source link

워크스페이스 등록 시 바로 로그인 가능 #675

Closed yeon-06 closed 1 year ago

yeon-06 commented 1 year ago

신규 기능 개발


목적

이번 기능 개발의 목적을 간단히 적어주세요

워크스페이스 등록 시 바로 로그인 가능



상세 내용

구현할 기능 관련 상세 내용을 적어주세요

기존에는 Slack scope 지정 문제로 해당 기능이 불가능하다 판단했었습니다. (https://github.com/woowacourse-teams/2022-pickpick/issues/633) 이번에 scope 지정을 변경하면서 해당 기능을 적용할 수 있게 되었습니다.



yeon-06 commented 1 year ago

트랜잭션 전파 REQUIRED vs REQUIRES_NEW

yeon-06 commented 1 year ago

한 클래스 내에서도 트랜잭션이 전파될까?

간단한 테스트 - 전파 안된다!🤬

테스트 환경: MySQL

 @Test
void test() {
    String account = "yeonLog";
    User user = new User(account, "연로그", "pwd1234", Level.BASIC);
    userDao.save(user);

    System.out.println("before: " + userDao.findById(account));

    userService.readOnlyTransactionWithTransaction(user);
    System.out.println("after: " + userDao.findById(account));
}

아래 사진을 보면 update 하는 메서드에서는 @Transactional로 설정했음에도 read-only니까 변경이 불가능하다고 뜬다. image


스프링 공식 문서 🍃

https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#transaction-declarative-annotations

This means that self-invocation (in effect, a method within the target object calling another method of the target object) does not lead to an actual transaction at runtime even if the invoked method is marked with @Transactional.

같은 오브젝트에서 다른 메서드를 호출해도 트랜잭션 동작이 안됩니다.

yeon-06 commented 1 year ago

트랜잭션이 적용되지 않던 상황에 대해 개인 블로그에 디테일하게 서술해놓았습니다.