물론 학부시절에는 롤백보다는 일단 life cycle 을 익히고 실행/동작하는것에 focus가 맞춰있다보니 이젠 이런 내용들을 .....
선언적 트랜잭션
2. 설정 파일이나 어노테이션을 이용해서 트랜잭션의 범위, 롤백의 규칙을 정의
방법 :
1.<tx:advice> 태그를 이용한 트랜잭션 처리
여기서 소개할 트랜잭션 처리 방식은 2.TransactionProxyFactoryBean과 3.@Transaction 을 이용한 두가지 방법이다.
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:ibatis/sql-map-config.xml</value>
</list>
</property>
<property name="useTransactionAwareDataSource">
<value>true</value>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<!-- Transaction manager for a single JDBC DataSource -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="abstractTxDefinition" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="clear*">PROPAGATION_REQUIRED</prop>
<prop key="rename*">PROPAGATION_REQUIRED</prop>
<prop key="move*">PROPAGATION_REQUIRED</prop>
<prop key="import*">PROPAGATION_REQUIRED</prop>
<prop key="set*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="store*">PROPAGATION_REQUIRED</prop>
<prop key="import*">PROPAGATION_REQUIRED</prop>
<prop key="request*">PROPAGATION_REQUIRED</prop>
<prop key="approve*">PROPAGATION_REQUIRED</prop>
<prop key="start*">PROPAGATION_REQUIRED</prop>
<prop key="execute*">PROPAGATION_REQUIRED</prop>
<prop key="*confirm*">PROPAGATION_REQUIRED</prop>
<prop key="*report*">PROPAGATION_REQUIRED</prop>
<prop key="*save*">PROPAGATION_REQUIRED</prop>
<prop key="redraft*">PROPAGATION_REQUIRED</prop>
<prop key="report*">PROPAGATION_REQUIRED</prop>
<prop key="apporove*">PROPAGATION_REQUIRED</prop>
<prop key="reject*">PROPAGATION_REQUIRED</prop>
<prop key="redraft*">PROPAGATION_REQUIRED</prop>
<prop key="accept*">PROPAGATION_REQUIRED</prop>
<prop key="copy*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED</prop>
<prop key="eval*">PROPAGATION_REQUIRED</prop>
<prop key="multi*">PROPAGATION_REQUIRED</prop>
<prop key="handle*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_SUPPORTS, readOnly</prop>
</props>
</property>
</bean>
<!-- DataSource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<!-- <property name="driverClassName" value="com.p6spy.engine.spy.P6spyDriver" /> -->
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
1.1 TransactionProxyFactoryBean
PROPAGATION_NAME, ISOLATION_NAME,readOnly,timeout,+Exception1,-Exception2
PROPAGATION_NAME :
- PROPAGATION_REQUEST와 같은 트랜잭션 전파 규칙이 위치한다.
- 예외클레스 이름앞에 '+'를 붙이면 해당 예외가 발생하더라도 커밋을 수행.
- '-'를 붙이면 롤백을 수행.
@Transactional
public class TestServiceImpl implements ITestService{
}
'Spring' 카테고리의 다른 글
spring 3.2 / tiles3 (2) | 2013.12.18 |
---|---|
facebook platform login/ 정보 연동 (java/jsp) (0) | 2013.12.10 |
Spring DI(Dependency Injection) 의존 - 내용수정중 (0) | 2012.01.09 |
Spring @annotation 사용시 주의점 및 사용 방법 ?? 수정중,.,.. (0) | 2011.11.17 |
spring annotation (0) | 2011.03.30 |