問(wèn)題描述
如果有人能解釋這個(gè)注釋的作用以及我們何時(shí)使用它:
if some one can explain what this annotation do and when exactly we use it :
@Transactional(propagation=Propagation.REQUIRED)
謝謝
推薦答案
當(dāng)傳播設(shè)置為 PROPAGATION_REQUIRED 時(shí),將為應(yīng)用該設(shè)置的每個(gè)方法創(chuàng)建一個(gè)邏輯事務(wù)范圍.每個(gè)這樣的邏輯事務(wù)范圍可以單獨(dú)確定僅回滾狀態(tài),外部事務(wù)范圍在邏輯上獨(dú)立于內(nèi)部事務(wù)范圍.當(dāng)然,在標(biāo)準(zhǔn) PROPAGATION_REQUIRED 行為的情況下,所有這些范圍都將映射到同一個(gè)物理事務(wù).因此,在內(nèi)部事務(wù)范圍內(nèi)設(shè)置的僅回滾標(biāo)記確實(shí)會(huì)影響外部事務(wù)實(shí)際提交的機(jī)會(huì)(正如您所期望的那樣).
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
這篇關(guān)于@Transactional(傳播=傳播.需要)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!