站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Transaction (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate
Interface Transaction

All Known Implementing Classes:
JDBCTransaction, JTATransaction

public interface Transaction

Allows the application to define units of work, while maintaining abstraction from the underlying transaction implementation (eg. JTA, JDBC).

A transaction is associated with a Session and is usually instantiated by a call to Session.beginTransaction(). A single session might span multiple transactions since the notion of a session (a conversation between the application and the datastore) is of coarser granularity than the notion of a transaction. However, it is intended that there be at most one uncommitted Transaction associated with a particular Session at any time.

Implementors are not intended to be threadsafe.

Author:
Anton van Straaten
See Also:
Session.beginTransaction(), TransactionFactory

Method Summary
 void commit()
          Flush the associated Session and end the unit of work.
 void rollback()
          Force the underlying transaction to roll back.
 boolean wasCommitted()
          Check if this transaction was successfully committed.
 boolean wasRolledBack()
          Was this transaction rolled back or set to rollback only?
 

Method Detail

commit

public void commit()
            throws HibernateException
Flush the associated Session and end the unit of work. This method will commit the underlying transaction if and only if the transaction was initiated by this object.

Throws:
HibernateException

rollback

public void rollback()
              throws HibernateException
Force the underlying transaction to roll back.

Throws:
HibernateException

wasRolledBack

public boolean wasRolledBack()
                      throws HibernateException
Was this transaction rolled back or set to rollback only?

Returns:
boolean
Throws:
HibernateException

wasCommitted

public boolean wasCommitted()
                     throws HibernateException
Check if this transaction was successfully committed. This method could return false even after successful invocation of commit().

Returns:
boolean
Throws:
HibernateException