transaction 관련문의
- 작성자 :
- 최*구
- 작성일 :
- 2010-11-29 15:39:29
- 조회수 :
- 2,949
- 구분 :
- 실행환경
- 진행상태 :
- 완료
Q
- 선언적 트랜잭션
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" rollback-for="Exception" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="requiredTx"
expression="execution(* kr.go.nvrqs.dpl..impl.*Impl.*(..))"/>
<aop:advisor advice-ref="txAdvice"
pointcut-ref="requiredTx" />
</aop:config>
- DAO 구현 트랜잭션
SqlMapClient smc = getSqlMapClient();
try {
/** Transaction Start */
smc.startTransaction();
/** 등록 및 수정 */
//....
/** commit transaction */
smc.commitTransaction();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
smc.endTransaction();
}
현재 선언적 트랜잭션으로 service impl 클래스에 트랜잭션 처리가 되 있습니다.
헌데 DAO 단에서 sqlmpaclient의 트랜잭션을 별도로 사용한놈을
impl 클래스에서 try ~ catch 에 선언하여 사용하고 있습니다.
별다른 exception은 없는상황에서 DAO단 만 exception을 발생시키면
해당 impl 클래스 전체가 롤백이 되는군요...
이상황이 어떤 건지 궁금합니다.
뭔가 잘못이 된건지도 궁금하군요
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" rollback-for="Exception" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="requiredTx"
expression="execution(* kr.go.nvrqs.dpl..impl.*Impl.*(..))"/>
<aop:advisor advice-ref="txAdvice"
pointcut-ref="requiredTx" />
</aop:config>
- DAO 구현 트랜잭션
SqlMapClient smc = getSqlMapClient();
try {
/** Transaction Start */
smc.startTransaction();
/** 등록 및 수정 */
//....
/** commit transaction */
smc.commitTransaction();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
smc.endTransaction();
}
현재 선언적 트랜잭션으로 service impl 클래스에 트랜잭션 처리가 되 있습니다.
헌데 DAO 단에서 sqlmpaclient의 트랜잭션을 별도로 사용한놈을
impl 클래스에서 try ~ catch 에 선언하여 사용하고 있습니다.
별다른 exception은 없는상황에서 DAO단 만 exception을 발생시키면
해당 impl 클래스 전체가 롤백이 되는군요...
이상황이 어떤 건지 궁금합니다.
뭔가 잘못이 된건지도 궁금하군요
A
안녕하세요.. 최성구님..
DAO에서 Exception을 catch로 잡으시는 경우는 transaction 처리가 되지 않습니다.
(catch 하더라도 다시 throw를 통해 전달해야 함)
추가로 DAO에서도 startTransaction()메소드와 같은 처리가 필요치 않습니다.
그럼.. 즐거운 하루 되십시오.
감사합니다.
DAO에서 Exception을 catch로 잡으시는 경우는 transaction 처리가 되지 않습니다.
(catch 하더라도 다시 throw를 통해 전달해야 함)
추가로 DAO에서도 startTransaction()메소드와 같은 처리가 필요치 않습니다.
그럼.. 즐거운 하루 되십시오.
감사합니다.