2. Spring Framework support, for property
1) PROPAGATION_REQUIRED - to support the current transaction, if does not exist to create a new one. This is the most common choice.
2) PROPAGATION_SUPPORTS - to support the current transaction, if there is no use of services.
3) PROPAGATION_MANDATORY - to support the current transaction, if does not exist throw an exception.
4) PROPAGATION_REQUIRES_NEW - to create a new transaction, and suspend the current transaction (if it exists).
5) PROPAGATION_NOT_SUPPORTED - do not use services, and suspend the current transaction (if it exists).
6) PROPAGATION_NEVER - do not use matters, if the current transaction will throw an exception exists.
7) PROPAGATION_NESTED - if the current exists, as embedded in matters regarding the implementation of transaction, or with PROPAGATION_REQUIRED similar.
1) PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED
PROPAGATION_REQUIRES_NEW start a new, does not depend on the environment of the "internal" affairs. This transaction will be fully commited or rolled back instead of relying on external affairs, the scope of its own isolation, their locks, and so on. When the internal affairs of the beginning executed, the external affairs will be suspended, the House Affairs, at the end of the external affairs will continue.
On the other hand, PROPAGATION_NESTED start a "nested" transaction, which is already existing services a real child transaction. Sets of potential transaction started, it will get a savepoint. If the nested transaction fails, we will roll back to this savepoint. submarine sets affairs are part of external affairs, only the external affairs after the end of it will be presented. Savepoint need the latest JDBC specification to support. JDBC3?
Thus, PROPAGATION_REQUIRES_NEW and PROPAGATION_NESTED the biggest difference is that, PROPAGATION_REQUIRES_NEW is a completely new transaction, while the PROPAGATION_NESTED is the External Affairs sub-transaction, if the external affairs commit, nested transaction will also be commit, this rule also applies to roll back .
2) Required and mandatory transaction attribute
Two kinds of support transaction context. If you call when there is no difference between the transaction context, Required to be launching a new business. The mandatory exception to be thrown.
Deep-seated differences based on the following rules:
With the exception of the stateful session bean, the method that starts a transaction must be the same method that terminates the transaction.
Required services can not be sure whether it is because in this method to start or come in from outside the pass, and therefore do not know whether to do this treatment rollback when an exception occurs. The Mandatory to confirm matters are imported from the outside, so know they do not need to deal with this logic.