Related configuration for "transactionattributes" in spring

Source: Internet
Author: User
<bean id= "Basetransactionproxy" class= " Org.springframework.transaction.interceptor.TransactionProxyFactoryBean "
lazy-init=" true "abstract=" true " >   
<property name= "TransactionManager" >   
<ref bean= "TransactionManager"  />   
</ property>   
<property name= "transactionattributes" >   
<props>   
<prop key= "insert*" > propagation_required,-exception</prop>   
<prop key= "update*" >propagation_required,-exception</ prop>   
<prop key= "delete*" >PROPAGATION_REQUIRED,-Exception</prop>   
<prop key= "get*" >PROPAGATION_REQUIRED,readOnly</prop>   
<prop key= "find*" >propagation_required,readonly</ prop>   
</props>   
</property>   
</bean>

propagation_required--supports the current transaction and creates a new transaction if there are currently no transactions. This is the most common choice.

propagation_supports--supports the current transaction and executes it in a non transactional manner if there are currently no transactions.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/

propagation_mandatory--supports 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 and suspends the current transaction if there is a current 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 a transaction is currently present. If there is currently no transaction, a similar operation is performed with Propagation_required. Methods to improve query speed of SQL statements

All current transactions use the "Propagation_required" property value, and the control of transaction permissions is read-only to ensure that the data is not updated at the time of the query.

The "propagation_required" attribute described above would create transactions for all operations, resulting in an update operation in the JPA log query, and thus inefficient.

To change the operation of all queries to a transaction type of "Propagation_never" (without a transaction), query efficiency is immediately elevated,

But at this point worry about a problem: for example, in a savexxx () method, if the method internal use of update, query, and then update the operation process, will not cause the call query, due to the above configuration caused by throwing an exception.

Other than that

-exception indicates that a transaction is rolled back when a exception is thrown. -On behalf of the Rollback + on behalf of the submission

ReadOnly is read only, set operation permissions for read-only, generally used to query the method, optimize the role.

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.