public class TransactionUtils extends Object
| 构造器和说明 |
|---|
TransactionUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
assertHasAffectedRow(int totalAffectedRow,
String errorMsg) |
static void |
assertHasAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier) |
static void |
assertNotAffectedRow(int totalAffectedRow,
String errorMsg) |
static void |
assertNotAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier) |
static void |
assertOneAffectedRow(int totalAffectedRow,
String errorMsg) |
static void |
assertOneAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier) |
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)
创建一个新事务,如果当前存在事务,则将这个事务挂起。
|
static boolean |
hasAffectedRow(int totalAffectedRow) |
static boolean |
isNotAffectedRow(int totalAffectedRow) |
static boolean |
isOneAffectedRow(int totalAffectedRow) |
public static boolean isNotAffectedRow(int totalAffectedRow)
public static boolean isOneAffectedRow(int totalAffectedRow)
public static boolean hasAffectedRow(int totalAffectedRow)
public static void assertNotAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier)
public static void assertNotAffectedRow(int totalAffectedRow,
String errorMsg)
public static void assertOneAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier)
public static void assertOneAffectedRow(int totalAffectedRow,
String errorMsg)
public static void assertHasAffectedRow(int totalAffectedRow,
Supplier<String> errorMsgSupplier)
public static void assertHasAffectedRow(int totalAffectedRow,
String errorMsg)
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 © 2024. All rights reserved.