public class TransactionUtils extends Object
| 构造器和说明 |
|---|
TransactionUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
doAfterTransactionCommit(Runnable action)
在事务提交后再执行
|
static <R> R |
doInNestedTransaction(org.springframework.transaction.PlatformTransactionManager txManager,
Throwables.ThrowingSupplier<R,Throwable> action,
Consumer<Throwable> log)
如果当前存在事务则开启一个嵌套事务,如果当前不存在事务则新建一个事务并运行。
|
static <R> R |
doInRequiresNewTransaction(org.springframework.transaction.PlatformTransactionManager txManager,
Throwables.ThrowingSupplier<R,Throwable> action,
Consumer<Throwable> log)
创建一个新事务,如果当前存在事务,则将这个事务挂起。
|
public static void doAfterTransactionCommit(Runnable action)
action - the action codepublic static <R> R doInRequiresNewTransaction(org.springframework.transaction.PlatformTransactionManager txManager,
Throwables.ThrowingSupplier<R,Throwable> action,
Consumer<Throwable> log)
内部事务与外部事务相互独立,互不依赖。
R - return typetxManager - the txManageraction - the action codelog - the exception logpublic static <R> R doInNestedTransaction(org.springframework.transaction.PlatformTransactionManager txManager,
Throwables.ThrowingSupplier<R,Throwable> action,
Consumer<Throwable> log)
内部事务为外部事务的一个子事务。
内部事务的提交/回滚不影响外部事务的提交/回滚
内部事务的提交/回滚最终依赖外部事务的提交/回滚。
R - return typetxManager - the txManageraction - the action codelog - the exception logCopyright © 2023. All rights reserved.