About the meaning of transactionattributes in the spring configuration _ transaction

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.