웹/spring
spring --13 트랜잭션
밍래그로프
2021. 2. 26. 16:21
1.pom.xml 에 spring-tx 추가
2.root-context 에 추가
1
2
3
4
|
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
|
cs |
3.transaction 설정의 테스트
@Transactional을 이용해서 설정 가능
-- 메소드 > 클래스 > 인터페이스 순의 우선순위를 가진다.
B> @Transactional
@Transactional 이 붙어있으면
수행을 할 때 수행이 제대로 되지 않으면 롤백을 자동으로 한다.
서로 연관된 테이블끼리의 연산 등에서
오류로 인해 ACID 원칙이 깨지는 것을 방지해준다.