उपयोग करने के लिए विभिन्न लेनदेन प्रचार रणनीतियां हैं। ये enum Propagation
में मौजूद हैं। जिनके लिए आप उपयोग करना चाहते हैं वे
/**
* Execute non-transactionally, suspend the current transaction if one exists.
* Analogous to EJB transaction attribute of the same name.
* <p>Note: Actual transaction suspension will not work on out-of-the-box
* on all transaction managers. This in particular applies to JtaTransactionManager,
* which requires the {@code javax.transaction.TransactionManager} to be
* made available it to it (which is server-specific in standard J2EE).
* @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager
*/
NOT_SUPPORTED(TransactionDefinition.PROPAGATION_NOT_SUPPORTED),
/**
* Execute non-transactionally, throw an exception if a transaction exists.
* Analogous to EJB transaction attribute of the same name.
*/
NEVER(TransactionDefinition.PROPAGATION_NEVER), // maybe not this one
तो इनमें से किसी के साथ अपनी कक्षा के अंदर विधि को एनोटेट करें।
@Transactional
public class MyTransactionalClass {
@Transactional(propagation = PROPAGATION_NOT_SUPPORTED)
public void nonTransactionalMethod() {...}
}
आप सभी प्रचार रणनीतियों here पा सकते हैं।
स्रोत
2013-08-14 15:09:24
क्या आपने '@ ट्रान्सएक्शनल (प्रचार = NOT_ समर्थित)' की कोशिश की है? –