Spring transaction management

Source: Internet
Author: User

Spring transaction management
A transaction is to treat a series of actions as a separate unit of work. these actions are either completed in full or all regardless of the four key properties of the transaction (ACID):-atomicity (atomicity): a transaction is an atomic operation consisting of a series of actions. the atomicity of the transaction ensures that the action is either completely completed or completely ineffective. -consistency: once all transaction actions are completed, the transaction is committed. data and resources are in a consistent state that satisfies business rules. -isolation: many transactions may process the same data at the same time. Therefore, each transaction should be isolated from other transactions to prevent data corruption. -durability: Once a transaction is completed, no matter what system error occurs, its results should not be affected. generally, transaction results are written to persistent storage. step 3: configure the Transaction Manager, configure the annotation driver, and add the @ Transactional annotation to the method.

<! -- Configure the Transaction Manager --> <! -- Jdbc Transaction Manager is cetcetransactionmanager Hibernate's Transaction Manager is HibernateTransactionManager --> <bean id = "transactionManager" class = "org. springframework. jdbc. datasource. dataSourceTransactionManager "> <property name =" dataSource "ref =" dataSource "> </property> </bean> <! -- Enable transaction annotation --> <tx: annotation-driven transaction-manager = "transactionManager"/>

 

Transaction propagation attributes when the transaction method is called by another transaction method, you must specify how the transaction should be propagated. for example, a method may continue to run in an existing transaction or start a new transaction and run it in its own transaction.

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.