KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > Transaction


1 //$Id: Transaction.java,v 1.4 2005/04/29 20:29:51 oneovthafew Exp $
2
package org.hibernate;
3
4 import javax.transaction.Synchronization JavaDoc;
5
6 /**
7  * Allows the application to define units of work, while
8  * maintaining abstraction from the underlying transaction
9  * implementation (eg. JTA, JDBC).<br>
10  * <br>
11  * A transaction is associated with a <tt>Session</tt> and is
12  * usually instantiated by a call to <tt>Session.beginTransaction()</tt>.
13  * A single session might span multiple transactions since
14  * the notion of a session (a conversation between the application
15  * and the datastore) is of coarser granularity than the notion of
16  * a transaction. However, it is intended that there be at most one
17  * uncommitted <tt>Transaction</tt> associated with a particular
18  * <tt>Session</tt> at any time.<br>
19  * <br>
20  * Implementors are not intended to be threadsafe.
21  *
22  * @see Session#beginTransaction()
23  * @see org.hibernate.transaction.TransactionFactory
24  * @author Anton van Straaten
25  */

26
27 public interface Transaction {
28
29     /**
30      * Flush the associated <tt>Session</tt> and end the unit of work.
31      * This method will commit the underlying transaction if and only
32      * if the transaction was initiated by this object.
33      *
34      * @throws HibernateException
35      */

36     public void commit() throws HibernateException;
37
38     /**
39      * Force the underlying transaction to roll back.
40      *
41      * @throws HibernateException
42      */

43     public void rollback() throws HibernateException;
44
45     /**
46      * Was this transaction rolled back or set to rollback only?
47      *
48      * @return boolean
49      * @throws HibernateException
50      */

51     public boolean wasRolledBack() throws HibernateException;
52
53     /**
54      * Check if this transaction was successfully committed. This method
55      * could return <tt>false</tt> even after successful invocation
56      * of <tt>commit()</tt>.
57      *
58      * @return boolean
59      * @throws HibernateException
60      */

61     public boolean wasCommitted() throws HibernateException;
62     
63     /**
64      * Is this transaction still active?
65      * @return boolean
66      */

67     public boolean isActive() throws HibernateException;
68     
69     /**
70      * Register a user synchronization callback for this transaction
71      */

72     public void registerSynchronization(Synchronization JavaDoc synchronization)
73     throws HibernateException;
74     
75 }
76
77
78
79
80
81
82
Popular Tags