码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 事务管理-Spring Framework transaction

时间:2015-04-07 17:53:57      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

public interface PlatformTransactionManager {
    TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException;    
            void commit(TransactionStatus status) throws TransactionException;    
            void rollback(TransactionStatus status) throws TransactionException;
}

The getTransaction(..) method returns a TransactionStatus object, depending on a TransactionDefinition parameter. The returned TransactionStatus might represent a new transaction, or can represent an existing transaction if a matching transaction exists in the current call stack. The implication in this latter case is that, as with Java EE transaction contexts, a TransactionStatus is associated with a thread of execution.

The TransactionDefinition interface specifies:

  • Isolation: 隔离性。The degree to which this transaction is isolated from the work of other transactions. For example, can this transaction see uncommitted writes from other transactions?

  • Propagation: 连续性。Typically, all code executed within a transaction scope will run in that transaction. However, you have the option of specifying the behavior in the event that a transactional method is executed when a transaction context already exists. For example, code can continue running in the existing transaction (the common case); 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: 超时。How long this transaction runs before timing out and being rolled back automatically by the underlying transaction infrastructure.

  • Read-only status: 只读。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 when you are using Hibernate.

public interface TransactionStatus extends SavepointManager {   
 boolean isNewTransaction();   
 boolean hasSavepoint();    
 void setRollbackOnly();    
 boolean isRollbackOnly();    
 void flush();    
 boolean isCompleted();
}


Spring 事务管理-Spring Framework transaction

标签:

原文地址:http://my.oschina.net/u/2308739/blog/396947

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!