Spring Transaction Propagation

이번글에서는 @Transactional propagation 에 대해서 정리해보겠다. 그 전에 트랜잭션 관리 방법에 대해서 간단하게 정리하겠다. Application 을 개발할 때, Transaction 관리를 두 가지중 선택할 수 있다. 1. Programmatic Transaction Management 2. Declarative Transaction Management Programmatic Transaction Management 는 말 그대로 Transaction 관리를 코드로 직접 구현한다. Declarative Transaction Management 는 해석하면 선언적 트랜잭션 관리이다. 흔히 Spring framework 를 사용할 때 설정을 해주며 트랜잭션이 필요한 비즈니스 로직을 구현할 때 @Transactional 어노테이션을 사용한다. 위에서 rollback 과 commit 을 코드로 관리하는 반면, AOP 를 통해서 관리된다. 따라서 보다 비즈니스 로직에 집중할 수 있다. Programmatic transaction management Vs Declarative transaction management Programmatic transaction management 는 보통 transaction 의 수가 적을 때 적합한 방식이다. 예를 들어, 자원에 대한 update operation 단지 몇 가지일 경우이다. transaction proxies 설정을 원하지 않을 때 적합하다. 이러한 경우에, TransactionTemplate 을 사용하는 것이 좋다. 반대로, application 이 수많은 transaction operation 이 필요할 경우, Declarative transaction management 가 더 적합하다. 이는 business logic 과 transaction management 을 분리시켜 주며, 설정 또한 그리 어렵지 않다. Spring framework 를 사용할 때, transaction ma...