2013-03-18 118 views
6

如果啓用自動提交,會回滾工作嗎?如果不是,那麼關閉自動確認的含義是什麼?如果自動提交是真的,@Transactional註釋是否工作?

@Transactional(rollbackFor = {ManagerException.class}) 
public myMethod()....{ 
    System.out.printLn(my_spring_stored_procedure.getDataSource() 
      .getConnection().getAutoCommit()) //true 
    .... 
    try { 
     result = this.my_spring_stored_procedure.execute(params); 
    }catch(DataAccessException e){ 
     throw new ManagerException(e); 
    } 
} 
+0

按定義,不,但Spring可能能夠禁用自動提交以使其工作。我很想看到答案。 +1好問題 – Brandon 2013-03-18 12:37:20

回答

1

是的。如果你檢查代碼,你會發現當春天使用這種方式來完成交易。如果你的配置是自動提交是真實的,那麼它會將其更改爲false,並在事務處理後將其更改爲true。

相關問題