@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