2013-10-12 2 views
1

Exception이없는 동안 트랜잭션이 롤백되는 이유는 무엇입니까? 개체가 저장되지 않습니다. 내가 좋아하는 트랜잭션 매개 변수 정의 :Spring의 transactionManager가 롤백 중이며 testexception = [null]입니다!

@Transactional(value = "transactionManager", timeout = 30, rollbackFor = 
java.lang.Exception.class)`. 

를이 로그 트랜잭션에 대해 말할 것입니다.

------------------------------------------------------------------------------- 
Test set: sample.library.dao.DAOTest 
------------------------------------------------------------------------------- 
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.634 sec 

무슨 일을하고 있어요 :

org.springframework.test.context.transaction.TransactionalTestExecutionListener 
endTransaction 
INFO: Rolled back transaction after test execution for test context [[email protected] 
testClass = DAOTest, testInstance = [email protected], testMethod = 
[email protected], testException = [null], mergedContextConfiguration = 
[[email protected] testClass = DAOTest, locations = 
'{classpath:/applicationcontext.xml}', classes = '{}', contextInitializerClasses = '[]', 
activeProfiles = '{}', contextLoader = 
'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = 
[null]]] 
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.634 sec 

여기 DAOTest 클래스의 전체 로그는? 필요한 경우 더 많은 정보를 제공 할 수 있습니다.

답변

4

INFO 레벨은 오류 메시지가 아님을 암시해야합니다. 서비스 수준 방법의 기본 설정에 관계없이 테스트는 기본적으로 롤백됩니다. 롤백을 피하려면 (실제로 원한다면) Spring 문서의 Annotations section of the Testing chapter에 설명 된대로 테스트 클래스 자체에 주석이 필요하다. 문제의 특수 효과는 @Rollback입니다.