您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

整个类的事务注释+排除单个方法

整个类的事务注释+排除单个方法

有不同的事务传播策略可以使用。这些存在于枚举中@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() {...}
}

您可以在此处找到所有传播策略。

其他 2022/1/1 18:21:08 有506人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶