我有一個方法說LogErrorA與Spring.Net的[Transaction]屬性,我想調用另一個方法(比如說LogErrorB),它也有[Transaction]屬性,因爲我有時需要直接調用它。 LogErrorA調用將在Spring.NET的一個事務中工作,或者多個事務將被創建?如果方法A調用方法B並且都具有[Transaction]屬性,會發生什麼情況?
[Transaction]
public virtual void LogErrorA()
[Transaction]
public virtual void LogErrorB()
而LogErrorA在LogErrorB內調用。
此外,LogErrorB可以直接調用一些時間。
您的回答給了我很好的信息。所以,我將使用「[Transaction(TransactionPropagation.Required)]」。但我認爲這是默認的,所以我不必做任何事情。我應該保留屬性。對? – 2014-10-06 10:02:34
看來這是根據此頁面的默認值:http://www.springframework.net/doc-1.1-P3/reference/html/transaction.html。請讓我知道如果我忘記了什麼.. – 2014-10-06 10:06:19
是的,'Propagation.Required'是默認的屬性值,所以你可以留下屬性,它會認爲它是Transaction.Required。有關交易的更多信息,請參閱此文檔: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/transaction/annotation/Transactional.html – 2014-10-06 10:06:28