@Transactionl annotations

Source: Internet
Author: User

The spring transaction annotations default encounters the throw new RuntimeException ("..."); the throw new Exception ("...") that needs to be captured will be rolled back; not rolled back
//Specify Rollback@Transactional (rollbackfor=exception.class)      Public voidMethodName () {//does not roll back       Throw NewException ("..."); } //specify not to roll back@Transactional (norollbackfor=exception.class)     PublicItimdaoimpl Getitemdaoimpl () {//will roll back        Throw NewRuntimeException ("Note"); }     //If there is a transaction, then join the transaction, and then create a new one (without writing the case) .@Transactional (propagation=propagation.required)//container does not open transactions for this method@Transactional (propagation=propagation.not_supported)//creates a new transaction regardless of whether a transaction exists, the original hangs, the new execution completes, and the old transaction continues@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 non-transaction, otherwise throws an exception (as opposed to propagation.mandatory)@Transactional (propagation=propagation.never)//If the other bean calls this method and declares the transaction in another bean, the transaction is used. If the other bean does not declare the transaction, then there is no transaction.@Transactional (propagation=propagation.supports)/*Public void MethodName () {//Modify Method 1 of this class update ();       Call the modification method of the other class otherbean.update ();    Modification method of this Class 2 update (); } Other failure does not affect this class of modification submitted successfully this type of update failure, other also failed*/@Transactional (Propagation=propagation.nested)//Readonly=true read-only, can be inserted, but cannot be updated, deleted@Transactional (propagation = propagation.required,readonly=true) //setting the time-out period@Transactional (propagation = propagation.required,timeout=30)//Setting the database isolation level@Transactional (propagation = Propagation.required,isolation=isolation.default)

@Transactionl annotations

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.