有不同的事务传播策略可以使用。这些存在于枚举中@H_403_1@Propagation。您可能要使用的是
@H_403_1@/** * 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-@R_586_2419@ * 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
@H_403_1@@Transactional public class MyTransactionalClass { @Transactional(propagation = Propagation.NOT_SUPPORTED) public void nonTransactionalMethod() {...} }
您可以在此处找到所有传播策略。