Spring Management

Spring transaction isolation level, which has several?

TransactionDefinition interface defines five levels of isolation represent constants:

  • TransactionDefinition.ISOLATION_DEFAULT: Use the default isolation level back-end database, Mysql default isolation level used REPEATABLE_READ Oracle defaults of READ_COMMITTED isolation level.
  • TransactionDefinition.ISOLATION_READ_UNCOMMITTED: lowest isolation level, allowing the data to change the reading has not been submitted, may cause dirty reads, non-repeatable reads or phantom reads
  • TransactionDefinition.ISOLATION_READ_COMMITTED: allow concurrent transactions to read data already submitted, can prevent dirty reads, but phantom reads or non-repeatable read may still occur
  • TransactionDefinition.ISOLATION_REPEATABLE_READ: repeatedly reading the results of the same field are the same, unless the data is modified their affairs themselves, you can prevent dirty reads and non-repeatable reads, but phantom reads still occur.
  • TransactionDefinition.ISOLATION_SERIALIZABLE: the highest level of isolation, full compliance ACID isolation levels. All transactions executed one by one in sequence, it is impossible to produce interference between such matters, that is to say, this level prevents dirty reads, non-repeatable reads and phantom reads . But this will seriously affect the performance of the program. Under normal circumstances you do not need this level.

Spring transaction in which several transaction propagation behavior?

Support the current transaction situation:

  • TransactionDefinition.PROPAGATION_REQUIRED: If the current transaction exists, it is added to the transaction; if no transaction, create a new business.
  • TransactionDefinition.PROPAGATION_SUPPORTS: If the current transaction exists, it is added to the transaction; if no transaction, non-transactional way places continue to run.
  • TransactionDefinition.PROPAGATION_MANDATORY: If the current transaction exists, it is added to the transaction; if no transaction, an exception is thrown. (Mandatory: Mandatory)

It does not support the current transaction situation:

  • TransactionDefinition.PROPAGATION_REQUIRES_NEW: create a new transaction, if the current transaction exists, put the current transaction pending.
  • TransactionDefinition.PROPAGATION_NOT_SUPPORTED: non-transaction run, if the current transaction exists, put the current transaction pending.
  • TransactionDefinition.PROPAGATION_NEVER: non-transaction run, if the current transaction exists, an exception is thrown.

Other situations:

  • TransactionDefinition.PROPAGATION_NESTED: If the current transaction exists, create a transaction to run as the current nested transaction transaction; if no transaction, the value is equivalent to TransactionDefinition.PROPAGATION_REQUIRED.

Guess you like

Origin www.cnblogs.com/fanyongqing/p/12466520.html