티스토리 뷰

가. @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
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함