Announcement Announcement Module
Collapse
No announcement yet.
throw sqlexception but no rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • throw sqlexception but no rollback

    hi all,

    I am following the example to test the transaction management function of springframework core 2.5.6

    http://static.springsource.org/sprin...on-declarative

    it works in throw the example exception

    15:07:52,392 DEBUG [RuleBasedTransactionAttribute] Winning rollback rule is: RollbackRuleAttribute with pattern [UnsupportedOperationException]
    15:07:52,392 DEBUG [DataSourceTransactionManager] Triggering beforeCompletion synchronization
    15:07:52,408 DEBUG [DataSourceTransactionManager] Initiating transaction rollback

    I also define one more exception in the applicationContext.xml which is SQLException.

    like.
    ..
    <tx:method name="insert*" rollback-for="SQLException,UnsupportedOperationException"/>
    ..
    but the Winning rollback rule is null this time when SQLException is thrown.
    any thing wrongs in setting?


    "15:20:54,123 DEBUG [RuleBasedTransactionAttribute] Winning rollback rule is: null
    15:20:54,123 DEBUG [RuleBasedTransactionAttribute] No relevant rollback rule found: applying superclass default"
    15:20:54,123 DEBUG [SQLErrorCodesFactory] SQL error codes for 'Oracle' found
    15:20:54,123 DEBUG [SQLErrorCodeSQLExceptionTranslator] Translating SQLException with SQL state '23000', error code '1400', message [ORA-01400: cannot insert NULL into ("PRSPRD"."PRS_TRAN_HISTORY_DETAILS"."CREATED_B Y")
    ]; SQL was [INSERT into PRS_TRAN_HISTORY_DETAILS values (?,?,?,?,?)] for task [PreparedStatementCallback]
    15:20:54,123 DEBUG [TransactionInterceptor] Completing transaction for [x.y.service.FooService.insertFoo] after exception: org.springframework.dao.DataIntegrityViolationExce ption: PreparedStatementCallback; SQL [INSERT into PRS_TRAN_HISTORY_DETAILS values (?,?,?,?,?)]; ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")
    ; nested exception is java.sql.SQLException: ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")

    15:20:54,123 DEBUG [RuleBasedTransactionAttribute] Applying rules to determine whether transaction should rollback on org.springframework.dao.DataIntegrityViolationExce ption: PreparedStatementCallback; SQL [INSERT into PRS_TRAN_HISTORY_DETAILS values (?,?,?,?,?)]; ORA-01400: cannot insert NULL into ("PRSPRD"."PRS_TRAN_HISTORY_DETAILS"."CREATED_B Y")
    ; nested exception is java.sql.SQLException: ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")

    15:20:54,123 DEBUG [RuleBasedTransactionAttribute] Winning rollback rule is: null
    15:20:54,123 DEBUG [RuleBasedTransactionAttribute] No relevant rollback rule found: applying superclass default
    15:20:54,123 DEBUG [DataSourceTransactionManager] Triggering beforeCompletion synchronization
    15:20:54,123 DEBUG [DataSourceTransactionManager] Initiating transaction rollback
    15:20:54,123 DEBUG [DataSourceTransactionManager] Rolling back JDBC transaction on Connection [jdbc:oracle:thin:@hy-pms-st02.corp.shkp.com.hk:1521mssit, UserName=PRSPRD, Oracle JDBC driver]
    15:20:54,123 DEBUG [DataSourceTransactionManager] Triggering afterCompletion synchronization
    15:20:54,123 DEBUG [TransactionSynchronizationManager] Clearing transaction synchronization
    15:20:54,123 DEBUG [TransactionSynchronizationManager] Removed value [org.springframework.jdbc.datasource.ConnectionHold er@149d886] for key [org.apache.commons.dbcp.BasicDataSource@90c06f] from thread [main]
    15:20:54,123 DEBUG [DataSourceTransactionManager] Releasing JDBC Connection [jdbc:oracle:thin:@hy-pms-st02.corp.shkp.com.hk:1521mssit, UserName=PRSPRD, Oracle JDBC driver] after transaction
    15:20:54,123 DEBUG [DataSourceUtils] Returning JDBC Connection to DataSource
    Exception in thread "main" org.springframework.dao.DataIntegrityViolationExce ption: PreparedStatementCallback; SQL [INSERT into PRS_TRAN_HISTORY_DETAILS values (?,?,?,?,?)]; ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")
    ; nested exception is java.sql.SQLException: ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")

    Caused by: java.sql.SQLException: ORA-01400: cannot insert NULL into ("PRS_TRAN_HISTORY_DETAILS"."CREATED_BY")
Working...
X