문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
springframework:transaction [2014/11/28 15:32] kwon37xi [Chained Transaction Manager] |
springframework:transaction [2022/11/09 14:45] kwon37xi [Spring Transaction] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Spring Transaction ====== | ====== Spring Transaction ====== | ||
+ | * [[springframework: | ||
+ | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
+ | |||
+ | ===== 내부 트랜잭션 메소드 호출 금지 ===== | ||
+ | * 기본 프록시 모드에서는 클래스의 메소드에서 동일 클래스의 '' | ||
+ | * 이는 AOP의 기본작동이 그렇기 때문이다. | ||
+ | * 따라서 항상 트랜잭션을 올바로 적용하려면 **현재 클래스의 메소드가 아닌 다른 클래스의 메소드에 트랜잭션을 걸어야만 한다.** | ||
+ | |||
+ | > In proxy mode (which is the default), **only external method calls coming in through the proxy are intercepted. This means that self-invocation, | ||
+ | |||
+ | ===== Circular (Cyclic) Dependency 금지 ===== | ||
+ | * Circular Dependency 인 Bean에 '' | ||
+ | * 이는 대부분의 AOP에서 동일하게 적용될 것으로 보임. Circular Dependency 를 항상 피하도록 한다. | ||
+ | |||
+ | ===== interface or class? ===== | ||
+ | * '' | ||
+ | * **Spring 문서는 class에 트랜잭션 애노테이션 걸기를 권장**하고 있다. | ||
+ | |||
+ | > Spring recommends that you **only annotate concrete classes (and methods of concrete classes) with the @Transactional annotation**, | ||
+ | |||
===== Read Only ===== | ===== Read Only ===== | ||
- | * [[http://www.codeinstructions.com/2009/ | + | * [[http://akaroice.tistory.com/20|hibernate flush VS commit :: 비상]] |
- | '' | + | '' |
이 힌트로 정말로 read only 트랜잭션이 생성될 수도 있고, MySQL 리플리케이션 JDBC 드라이버의 경우 Write가 있을 경우에는 Master로 read only일 경우에는 Slave로 커넥션을 맺는 식의 선택을 하는 정도의 역할만 할 수도 있다. | 이 힌트로 정말로 read only 트랜잭션이 생성될 수도 있고, MySQL 리플리케이션 JDBC 드라이버의 경우 Write가 있을 경우에는 Master로 read only일 경우에는 Slave로 커넥션을 맺는 식의 선택을 하는 정도의 역할만 할 수도 있다. | ||
줄 11: | 줄 32: | ||
Oracle JDBC 드라이버는 Read-Only 트랜잭션을 지원하며, | Oracle JDBC 드라이버는 Read-Only 트랜잭션을 지원하며, | ||
- | Spring-Hibernate 연동시에는 Session의 Flush Mode를 '' | + | Spring-Hibernate 연동시에는 Session의 Flush Mode를 '' |
줄 25: | 줄 46: | ||
===== Transaction 정보 처리 ===== | ===== Transaction 정보 처리 ===== | ||
* [[http:// | * [[http:// | ||
- | * [[http:// | + | * [[http:// |
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
줄 87: | 줄 108: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Timeout ===== | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== Programatic Transaction Managemen - TransactionTemplate ===== | ||
+ | * Progmatic transaction demarcation. | ||
+ | * API와 DB 호출이 한 트랜잭션으로 엮이거나 하면 커넥션 점유 시간이 증가하면서 커넥션 부족에 시달릴 수 있다. | ||
+ | * 또한 하나의 Bean 에서 트랜잭션이 없는 메소드가 트랜잭션이 있는 메소드를 호출 할 경우 작동하지 않는다. | ||
+ | * 이를 '' | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | ===== 참여 중인 트랜잭션이 실패하면 기본정책이 전역롤백 ===== | ||
+ | * [[http:// | ||
+ | * A -> B 메소드 호출되고 **A** 메소드에서 트랜잭션 시작되고 B 도 '' | ||
+ | * Hibernate의 경우 Hibernate 메소드 호출시 롤백 되면 무조건 롤백 마킹해버린다. | ||
+ | * [[https:// | ||
+ | * [[https:// |