Spring事务没有回滚

时间:2014-05-28 10:40:19

标签: spring spring-transactions

@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
public Long credit(int amount, Long accountNumber) throws SQLException {

//Account Information
//Amount would be credit from account and UPDATE in ACCOUNT TABLE       
Account account=accountRepository.findAccountByNumber(accountNumber);       
account.credit(amount);             
accountRepository.update(account);


//SOME RUNTIME EXCEPTION
if(true){
    throw new RuntimeException("Just for testing....");
}



//Transcation Details
//Acount transcation details would be store in TRANSCATION TABLE            
TransactionDetail toTransactionDetail=new TransactionDetail(accountNumber,new Date(),amount,TransactionType.CREDIT);            
Long transactionId=transactionRepository.addTransaction(toTransactionDetail);



return transactionId;

}

第一笔金额将是学分,然后帐户信息将在ACCOUNT表中更新,然后将Transcation信息插入TRANSCATION表,假设帐户更新和Transcation插入之间发生运行时异常,帐户更新(帐户表)没有回滚,什么回滚的问题是什么?

0 个答案:

没有答案