트랜잭션 추상화

스프링 트랜잭션 추상화의 핵심은 PlatformTranscationManager 인터페이스 이다

Untitled

public interface PlatformTransactionManager extends TransactionManager {
	TransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException;
	
  void commit(TransactionStatus status) throws TransactionException;

  void rollback(TransactionStatus status) throws TransactionException;
}

getTransaction() : 트랜잭션을 시작한다

→이미 진행중인 트랜잭션이 있는 경우 해당 트랜잭션에 참여 할 수 있다 (트랜잭션 전파 관련)

리소스 동기화

-트랜잭션을 유지하려면 트랜잭션의 시작~끝까지 동일한 데이터베이스 커넥션을 유지해야 한다

-현재 파라미터로 커넥션을 전달하는 방법은 코드의 중복과 유지보수를 어렵게 하는 여러 단점들이 존재한다

Untitled

*트랜잭션 매니저와 트랜잭션 동기화 매니저 사용

Untitled

동작 방식

① 트랜잭션 매니저는 데이터 소스를 통해 커넥션을 만들고 트랜잭션을 시작한다