-
[Spring] 예외 발생시 Spring DB 트랜잭션 롤백 안되는 경우Back End/Spring Framework 2024. 11. 27. 18:44
배경지식
- Checked Exception 은 개발자가 인지한 예외라 약속한다.
- Unchecked Exception 은 개발자가 인지하지 못한 예외라 약속한다.
- try-catch 문에서 catch 된 Exception 은 개발자가 인지한 예외라 약속한다.
- 스프링은 개발자가 인지한 예외에 대해서는 기본적으로 롤백을 진행하지 않는다.
- 예외가 발생한 메서드의 Propagation 레벨이 Required(default) 가 아니면 부모트랜잭션은 롤백되지 않는다.
- 프록시가 Self invocation 을 시도할 경우 경우에 따라 트랜잭션이 롤백되지 않을 수 있다.
[Spring] 트랜잭션에 대한 실험과 고찰 (Self-invocation, 프록시가 메서드를 실행하기까지의 과정)
[Spring] 예외 발생시 Spring DB 트랜잭션 롤백 안되는 경우배경지식Checked Exception 은 개발자가 인지한 예외라 약속한다.Unchecked Exception 은 개발자가 인지하지 못한 예외라 약속한다.try-catch 문에서 catc
developer-ping9.tistory.com
발생 케이스
- 발생한 예외가 Checked Exception
- @Transational 어노테이션에 rollbackFor 을 설정하지 않은 경우
- 발생한 예외가 Unchecked Exception
- try-catch 구문안에서 핸들링되는 경우 (Unchecked Exception 을 왜 잡으려고 하는거에요?)
- @Transational 어노테이션에 noRollbackFor 가 설정된 경우
- 자식 메서드의 Propagation 레벨이 Required 가 아닐 경우
- 프록시의 Self invocation 으로 인한 경우
Reference
Rolling Back a Declarative Transaction :: Spring Framework
You must carefully consider how specific a pattern is and whether to include package information (which isn’t mandatory). For example, "Exception" will match nearly anything and will probably hide other rules. "java.lang.Exception" would be correct if "E
docs.spring.io
응? 이게 왜 롤백되는거지? | 우아한형제들 기술블로그
이 글은 얼마 전 에러로그 하나에 대한 호기심과 의문으로 시작해서 스프링의 트랜잭션 내에서 예외가 어떻게 처리되는지를 이해하기 위해 삽질을 해본 경험을 토대로 쓰여졌습니다. 스프링의
techblog.woowahan.com
[이슈 #1] Spring Transaction의 Self Invocation 이슈
Spring Transaction의 Self Invocation 이슈 문제 인식 Spring Security를 이용한 OAuth 로그인 기능을 구현하기 위해 커스텀한 OAuth2UserService를 개발하던 중, 영속 상태에 있는 인스턴스의 필드 변경 사항이 DB에
yejun-the-developer.tistory.com
728x90'Back End > Spring Framework' 카테고리의 다른 글