Application of @Transactional annotations in spring-transactions

Source: Internet
Author: User


@Transactional Spring Transaction annotations
Default encounters throw new RuntimeException ("..."); Roll back
The throw new Exception ("...") that needs to be captured is not rolled back

Specifies that rollback @transactional (rollbackfor=exception.class) public void MethodName () {//Does not roll back the throw new Exception (    "...");  }//Specifies not to rollback @transactional (norollbackfor=exception.class) public Itimdaoimpl Getitemdaoimpl () {//will roll back the throw    New RuntimeException ("notes"); }//If there is a transaction, then add a transaction, no words to create a new (do not write) @Transactional (propagation=propagation.required)//container does not open the transaction for this method @Transac tional (propagation=propagation.not_supported)//regardless of whether a transaction exists, a new transaction is created, the original hangs, the new execution is complete, and the old transaction continues to execute @Transactional (    PROPAGATION=PROPAGATION.REQUIRES_NEW)//must be executed in an existing transaction or throw an exception @Transactional (propagation=propagation.mandatory) Must be executed in a transaction that does not, otherwise throws an exception (as opposed to propagation.mandatory) @Transactional (propagation=propagation.never)///If other beans call this method,    To declare a transaction in another bean, use a transaction. If the other bean does not declare the transaction, then there is no transaction. @Transactional (propagation=propagation.supports)//public void MethodName () {//Modify Method 1 update () for this class       ;       Call the modification method of the other class otherbean.update ();    How to modify this class 2   Update (); } Other failure does not affect the failure of this class of modification submission success of this type of update, other also failed */@Transactional (propagation=propagation.nested)//readonly=true Read Only , cannot update, delete @Transactional (propagation = propagation.required,readonly=true)//Set time-out @transactional (propagation = PROPAGATION.REQUIRED,TIMEOUT=30)//Set database Isolation level @transactional (propagation = propagation.required,isolation= Isolation.default)


Application of @Transactional annotations in spring-transactions

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.