类 ManualTransactionManager
java.lang.Object
io.github.mangocrisp.spring.taybct.tool.core.transaction.ManualTransactionManager
手动事务
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
commit
(org.springframework.transaction.TransactionStatus status) 提交事务void
rollback
(org.springframework.transaction.TransactionStatus status) 回滚事务org.springframework.transaction.TransactionStatus
start()
开启事务,并发回一个事务 TransactionStatus,后面可以通过这个 TransactionStatus 来操作事务提交或者回滚,这里使用默认传播性 PROPAGATION_REQUIREDorg.springframework.transaction.TransactionStatus
start
(int propagationBehavior) 开启事务,并发回一个事务 TransactionStatus ,后面可以通过这个 TransactionStatus 来操作事务提交或者回滚
Spring中七种事务传播行为
PROPAGATION_REQUIRED 如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中。
-
构造器详细资料
-
ManualTransactionManager
public ManualTransactionManager()
-
-
方法详细资料
-
start
public org.springframework.transaction.TransactionStatus start()开启事务,并发回一个事务 TransactionStatus,后面可以通过这个 TransactionStatus 来操作事务提交或者回滚,这里使用默认传播性 PROPAGATION_REQUIRED- 返回:
- tx key
-
start
public org.springframework.transaction.TransactionStatus start(int propagationBehavior) 开启事务,并发回一个事务 TransactionStatus ,后面可以通过这个 TransactionStatus 来操作事务提交或者回滚
Spring中七种事务传播行为
PROPAGATION_REQUIRED 如果当前没有事务,就新建一个事务,如果已经存在一个事务中,加入到这个事务中。这是最常见的选择。
PROPAGATION_SUPPORTS 支持当前事务,如果当前没有事务,就以非事务方式执行。
PROPAGATION_MANDATORY 使用当前的事务,如果当前没有事务,就抛出异常。
PROPAGATION_REQUIRES_NEW 新建事务,如果当前存在事务,把当前事务挂起。
PROPAGATION_NOT_SUPPORTED 以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。
PROPAGATION_NEVER 以非事务方式执行,如果当前存在事务,则抛出异常。
PROPAGATION_NESTED 如果当前存在事务,则在嵌套事务内执行。如果当前没有事务,则执行与PROPAGATION_REQUIRED类似的操作。- 参数:
propagationBehavior
- 事务传播行为- 返回:
- TransactionStatus
- 另请参阅:
-
TransactionDefinition
-
commit
public void commit(org.springframework.transaction.TransactionStatus status) 提交事务- 参数:
status
- TransactionStatus
-
rollback
public void rollback(org.springframework.transaction.TransactionStatus status) 回滚事务- 参数:
status
- TransactionStatus
-