Spring Transaction Management-spring Framework transaction

Source: Internet
Author: User

Public interface Platformtransactionmanager {transactionstatus gettransaction (transactiondefinition definition)                Throws TransactionException;                void commit (Transactionstatus status) throws TransactionException; void rollback (Transactionstatus status) throws TransactionException;}

thegetTransaction(..)method returns aTransactionStatusobject, depending on aTransactionDefinitionparameter. The ReturnedTransactionStatusmight represent a new transaction, or can represent an existing transaction if a matching transaction exists in the C Urrent Call stack. The implication-latter case is, as with Java EE transaction contexts, aTransactionStatusis associated with aThreadof execution.

The TransactionDefinition interface specifies:

  • isolation: Isolation. The degree to which this transaction are isolated from the work of other transactions. For example, can this transaction see uncommitted writes from other transactions?

  • propagation: Continuity. Typically, all code executed within a transaction scope would run in that transaction. However, you had the option of specifying the behavior in the event that a transactional method was executed when a Transa Ction context already exists. For example, code can continue running in the existing transaction (the common case); The or the existing transaction can be suspended and a new transaction created. Spring offers all of the transaction propagation options familiar from EJB CMT. To read about the semantics of transaction propagation in Spring, see section 11.5.7, "Transaction propagation".

  • timeout: Timed out. How long this transaction runs before timing out and being rolled back automatically by the underlying transaction infrast Ructure.

  • read-only status: Read only. A read-only transaction can be used when your code reads but does not modify data. Read-only transactions can be a useful optimization in some cases, such as while you are using Hibernate.

Public interface Transactionstatus extends Savepointmanager {boolean isnewtransaction ();     Boolean hassavepoint ();     void Setrollbackonly ();     Boolean isrollbackonly ();     void Flush (); Boolean iscompleted ();}


Spring Transaction Management-spring Framework 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.