7. iBATIS + Spring + transaction
1. 코드 기반의 트랜잭션 처리 (Progrmmatic Transaction)
2. 선언적 트랜잭션 (Declarative Transaction)
- <tx:advice> 태그를 이용
- TransactionProxyFactoryBean 태그를 이용
- @Transactional 어노테이션을 이용
<tx:advice> 태그 이용
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="fooService" class="x.y.service.DefaultFooService"/>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:method name="get*" read-only="true"/>
<tx:method name="*"/>
<aop:pointcut id="fooServiceOperation" expression="execution(* x.y.service.FooService.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/>
@ Transactional 어노테이션을 이용
@Transactional(readOnly = true)
public class DefaultFooService implements FooService {
public Foo getFoo(String fooName) {
// do something
}
// these settings have precedence for this method
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void updateFoo(Foo foo) {
// do something
}
}
<bean id="fooService" class="x.y.service.DefaultFooService"/>
<tx:annotation-driven transaction-manager="txManager"/>
'backend > iBatis' 카테고리의 다른 글
[iBatis] iBatis에서 Log4j를 이용하여 쿼리를 로그로 남기려면? (4) | 2009.01.20 |
---|---|
[iBatis] 자동 생성 Key (2) | 2009.01.18 |
[iBatis] 자바빈즈와 Map 타입의 결과 (0) | 2009.01.18 |
[iBATIS] 8. Annotation 기반으로 JUnit4를 이용한 Spring TDD ~ 9. Reference (4) | 2008.09.03 |
[iBATIS] 6. iBATIS + Spring (0) | 2008.09.01 |
[iBATIS] 5. Transaction (2) | 2008.09.01 |
[iBATIS] 4. How to (2) | 2008.08.29 |
[iBATIS] 1.Overview ~ 3. Introduce iBATIS (4) | 2008.08.28 |