Everybody prawns is good, younger brother is looking at spring recently, who can explain the configuration below.
<bean id= "Persister"
class= "Org.springframework.transaction.interceptor.TransactionProxyFactoryBean" >
<property name= "TransactionManager" ><ref bean= "TransactionManager"/></property>
<property name= "target" ><ref bean= "Reftarget"/></property>
<property name= "Transactionattributes" >
<props>
<prop key= "MyMethod" >propagation_required,-exception</prop>
</props>
</property>
</bean>
The last thing I understand is this sentence:
<prop key= "MyMethod" >propagation_required,-exception</prop>
What is the meaning behind the-exception, in addition, some code this line inside also has ReadOnly, all represents what meaning.
Solutions»
It is the disposition of the thing control ....
Prop key is the method name, which can contain the * wildcard character, propagation_required is a common choice, can be understood as greate or replace things, ReadOnly is set operation permission is read-only,
-exception forgot to say that this rep throws an exception, then the method rolls back ...-on behalf of the Rollback + on behalf of the submission ....
What is the meaning behind the-exception, in addition, some code this line inside also has ReadOnly, all represents what meaning. Indicates that a transaction is rolled back when a exception is thrown. ReadOnly is read only, generally used to query the method, optimize the role.
Types of transactional propagation behavior
Spring provides 7 types of transactional propagation behavior in the Transactiondefinition interface.
They specify how transactions propagate when the transaction method and transaction method occur when nested calls are made:
Table 1 Transactional propagation behavior types
Transactional propagation behavior Type
Description
Propagation_required
If there is currently no transaction, create a new transaction, if there is already a transaction, join in the transaction. This is the most common choice.
Propagation_supports
Supports the current transaction, which is performed in a non transactional manner if there are currently no transactions.
Propagation_mandatory
Uses the current transaction and throws an exception if there are currently no transactions.
Propagation_requires_new
Creates a new transaction and suspends the current transaction if there is currently a transaction.
propagation_not_supported
Performs an operation in a non transactional manner, suspending the current transaction if there is currently a transaction.
Propagation_never
Executes in a non transactional manner and throws an exception if there is a current transaction.
propagation_nested
Executes within a nested transaction if there is currently a transaction. If there is currently no transaction, a similar operation is performed with Propagation_required.