Yabo Sports DAO persistence

Yabo Sports yb9461 analysis DAO persistence of meaning.
2.1 Transaction

In a transaction method, call the other methods of transaction, the transaction at this time how to communicate, propagate, according to what rules.

1.1 transaction propagation rules a situation: the need to comply with the current transaction

REQUIRED: there must be a transaction, if there is a current transaction, then added to the transaction, otherwise a new transaction; (use more)
SUPPORTS,: support for the current transaction. If the current transaction exists, use the transaction or run in a non-transactional form;
MANDATORY: must be present transaction, if and when there is a transaction, you use the transaction, otherwise, an exception is thrown;
1.2 transaction propagation rules Case 2: non-compliance with the current transaction

REQUIRES_NEW: Regardless of whether there is currently Affairs, will be the new open a transaction must be a new transaction; (used more)
NOT_SUPPORTED: performed in a non-transactional way, if the current transaction exists, the current transaction is suspended;
NEVER: does not support transactions, If the current transaction is present, an exception is thrown;
1.3 where three transaction propagation rules: parasitic transaction (transaction external / internal Affairs / nested transaction)

HESTED: parasitic affairs, if the current transaction exists, is executed in the internal affairs; if the transaction does not currently exist, create a new transaction;
parasitic transaction can be achieved through a database savePoint (save points), parasitic transactions can be rolled back, but he does not roll back the influence of external affairs, but external affairs of the rollback will affect the parasitic affairs..
1.4 <tx: method, /> element's attributes (method to be enhanced)

name: the method name transaction management, support the use of wildcards ways: * pattern matching method of
propagation: propagation rules Affairs, default REQUIRED
Isolation: The transaction isolation level, the default DEFAULT follow the data table
timeout: transaction timeout, follow the default database
read- only: whether it is read-only transactions, for the query
rollback-for: do encounter any type of abnormal transaction rollback, the default java.lang.RuntimeException
NO--ROL lback for: what type of anomaly encountered no rollback
2. configuration affairs

Based xml: Enhanced configuration, configurations and enhanced number of settings corresponding Joinpoint, and entry points arranged reinforcing section Pointcut;
based annotation: Configuration @Transactional (annotation can be attached to the class / method) based on the service configured tx Notes parser and transaction management practical classes (IOC and DI have to comment parser configuration);

Guess you like

Origin blog.51cto.com/14654265/2462671