资源描述:
《解惑 spring 嵌套事务与ejb事务》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、解惑spring嵌套事务/***@author王政*@date2006-11-24*@note转载请注明出处*/在所有使用spring的应用中,声明式事务管理可能是使用率最高的功能了,但是,从我观察到的情况看,绝大多数人并不能深刻理解事务声明中不同事务传播属性配置的的含义,让我们来看一下TransactionDefinition接口中的定义代码/***Supportacurrenttransaction,createanewoneifnoneexists.*AnalogoustoEJBtransactionattributeofthesamename.*
Thisistypically
2、thedefaultsettingofatransactiondefinition.*/intPROPAGATION_REQUIRED=0;/***Supportacurrenttransaction,executenon-transactionallyifnoneexists.*AnalogoustoEJBtransactionattributeofthesamename.*
Note:Fortransactionmanagerswithtransactionsynchronization,*PROPAGATION_SUPPORTSisslightlydifferentfromnot
3、ransactionatall,*asitdefinesatransactionscoppthatsynchronizationwillapplyfor.*Asaconsequence,thesameresources(JDBCConnection,HibernateSession,etc)*willbesharedfortheentirespecifiedscope.Notethatthisdependson*theactualsynchronizationconfigurationofthetransactionmanager.*@seeorg.springframework.tran
4、saction.support.AbstractPlatformTransactionManager#setTransactionSynchronization*/intPROPAGATION_SUPPORTS=1;/***Supportacurrenttransaction,throwanexceptionifnoneexists.*AnalogoustoEJBtransactionattributeofthesamename.*/intPROPAGATION_MANDATORY=2;/***Createanewtransaction,suspendthecurrenttransacti
5、onifoneexists.*AnalogoustoEJBtransactionattributeofthesamename.*
Note:Actualtransactionsuspensionwillnotworkonout-of-the-box*onalltransactionmanagers.ThisinparticularappliestoJtaTransactionManager,*whichrequiresthejavax.transaction.TransactionManager
tobe*madeavailableittoit(whichiss
6、erver-specificinstandardJ2EE).*@seeorg.springframework.transaction.jta.JtaTransactionManager#setTransactionManager*/intPROPAGATION_REQUIRES_NEW=3;/***Executenon-transactionally,suspendthecurrenttransactionifoneexists.*AnalogoustoEJBtransactionattributeofthesamename.*
Note:Actualtransactionsuspen
7、sionwillnotworkonout-of-the-box*onalltransactionmanagers.ThisinparticularappliestoJtaTransactionManager,*whichrequiresthejavax.transaction.TransactionManager
tobe*madeavailableittoit(whichisserver-spe