Get the App
SLTechnology News&Howtos  ›  Development  › 

What's the use of transactionmanager?

Shulou Source: shulou.com Published: 2022-06-03 11:01:33 11月15日 Update

This article mainly introduces the use of transactionmanager, the article is very detailed, has a certain reference value, interested friends must read it!

First acquaintance of transactionmanager

A transaction is a logical set of operations that either succeed or fail.

Transactions have ACID features. Refer to Baidu encyclopedia as follows:

Atomicity (Atomicity): all operations in the whole transaction are either completed or not completed, and cannot be stuck in the middle.

Consistency: transactions must always keep the system in a consistent state, regardless of the number of concurrent transactions at any given time.

Isolation: transactions are executed in an isolated state so that they appear to be the only operations performed by the system at a given time.

Durability: after the transaction completes, the changes made by the transaction to the database are persisted in the database and are not rolled back.

Transactionmanager core interface API

Image

As shown in the figure above, there are three main high-level abstractions for Spring transaction management:

PlatformTransactionManager: transaction manager (used to manage transactions, including transaction commit, rollback)

TransactionDefinition: transaction definition information (isolation, propagation, timeout, read-only)

TransactionStatus: specific running status of the transaction

PlatformTransactionManager Core transaction Manager

Is the core interface of Spring's transaction manager.

Spring itself does not support transaction implementation, but is responsible for wrapping the underlying transaction. What kind of transaction strategy is supported by the application, what kind of transaction strategy Spring supports.

It provides common ways to manipulate transactions:

TransactionStatusgetTransaction (TransactionDefinitiondefinition): get transaction status information

Voidcommit (TransactionStatusstatus): commit transaction

Voidrollback (TransactionStatusstatus): rollback transactions

PublicinterfacePlatformTransactionManager (). {

/ / get the TransactionStatus object from TransactionDefinition

TransactionStatusgetTransaction (TransactionDefinitiondefinition) throwsTransactionException

/ / submit

Voidcommit (TransactionStatusstatus) throwsTransactionException

/ / rollback

Voidrollback (TransactionStatusstatus) throwsTransactionException

}

The above is all the content of this article "what's the use of transactionmanager?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Transaction management transaction management state or core support isolation consistency information content underlying interface data database time policy article system reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL macOS Docker MariaDB