問題描述
如果有人能解釋這個注釋的作用以及我們何時使用它:
if some one can explain what this annotation do and when exactly we use it :
@Transactional(propagation=Propagation.REQUIRED)
謝謝
推薦答案
當傳播設置為 PROPAGATION_REQUIRED 時,將為應用該設置的每個方法創建一個邏輯事務范圍.每個這樣的邏輯事務范圍可以單獨確定僅回滾狀態,外部事務范圍在邏輯上獨立于內部事務范圍.當然,在標準 PROPAGATION_REQUIRED 行為的情況下,所有這些范圍都將映射到同一個物理事務.因此,在內部事務范圍內設置的僅回滾標記確實會影響外部事務實際提交的機會(正如您所期望的那樣).
When the propagation setting is PROPAGATION_REQUIRED, a logical transaction scope is created for each method upon which the setting is applied. Each such logical transaction scope can determine rollback-only status individually, with an outer transaction scope being logically independent from the inner transaction scope. Of course, in case of standard PROPAGATION_REQUIRED behavior, all these scopes will be mapped to the same physical transaction. So a rollback-only marker set in the inner transaction scope does affect the outer transaction's chance to actually commit (as you would expect it to).
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/transaction.html
這篇關于@Transactional(傳播=傳播.需要)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!