가. @Transactional 활성화
⇒ 반드시 root-context.xml에 등록한다.
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- (this dependency is defined somewhere else) -->
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
나. 서비스클래스에서 메서드 레벨에 @Transactional 지정 ( 클래스 레벨에 지정하면 클래스내의 모든 메서드가 트랜잭션으로 처리가 된다. )
@Transactional
public int insertXXX(DeptDTO dto){
//DAO연동하면서 트랜잭션 처리
dao.insert(dto);
dao.update(20);
}
'Framework > SPRING FRAMEWORK' 카테고리의 다른 글
file upload (0) | 2023.09.20 |
---|---|
MyBatis 연동 - INSERT (0) | 2023.09.18 |
Spring MVC + Mybatis 연동 (0) | 2023.09.18 |
JSP에서 리소스 접근 (Image, js, css) (0) | 2023.09.18 |
Interceptor (가로채기) (0) | 2023.09.18 |