05.Spring 事务管理

Spring 事务

Spring 事务简介

数据层有事务我们可以理解,为什么业务层也需要处理事务呢?

举个简单的例子,

Spring 为了管理事务,提供了一个平台事务管理器 PlatformTransactionManager

public interface PlatformTransactionManager {
    TransactionStatus getTransaction(@Nullable TransactionDefinition var1) throws TransactionException;

    void commit(TransactionStatus var1) throws TransactionException;

    void rollback(TransactionStatus var1) throws TransactionException;
}