Spring's transaction mechanism

Transaction Principle
  Atomic
  Consistency
  Isolation
  Persistence

Mysql Transaction Principle
Read Uncommitted (read uncommitted content)
Read Committed (read committed content)
Repeatable Read (re-readable) Mysql default
Serializable (serializable)

spring provides for transactions Better management, bringing out the propagation level of

the transaction Transaction propagation behavior type

Description

PROPAGATION_REQUIRED

If there is no current transaction, create a new transaction, if there is already a transaction, join the transaction. This is the most common choice.

PROPAGATION_SUPPORTS

supports the current transaction, if there is no current transaction, it is executed in a non-transactional manner.

PROPAGATION_MANDATORY

uses the current transaction and throws an exception if there is no current transaction.

PROPAGATION_REQUIRES_NEW

Create a new transaction. If there is a current transaction, suspend the current transaction.

PROPAGATION_NOT_SUPPORTED

performs the operation in a non-transactional manner, suspending the current transaction if there is a current transaction.

PROPAGATION_NEVER

executes in a non-transactional manner, throwing an exception if a transaction currently exists.

PROPAGATION_NESTED

If a transaction currently exists, execute within a nested transaction. If there are no current transactions, do something similar to PROPAGATION_REQUIRED.

Reference article:
Spring transaction structure: http://www.cnblogs.com/davidwang456/p/4309038.html
MySQL transaction example: http://xm-king.iteye.com/blog/770721

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326928816&siteId=291194637