org.dasein.persist
Class Transaction

java.lang.Object
  extended by org.dasein.persist.Transaction

public class Transaction
extends Object

Represents a database transaction to applications managing their own transactions. To use this class, call getInstance() to get a transaction and pass that transaction to all Execution objects that need to execute in the same transaction context.
Last modified: $Date: 2007/02/24 19:27:48 $

Version:
$Revision: 1.13 $
Author:
George Reese

Method Summary
 void close()
          Closes the transaction.
 void commit()
          Commits the transaction to the database and closes the transaction.
 Map<String,Object> execute(Class<? extends Execution> cls, Map<String,Object> args)
           
 Map<String,Object> execute(Class<? extends Execution> cls, Map<String,Object> args, String dsn)
           
 HashMap<String,Object> execute(Execution event, Map<String,Object> args)
          Deprecated. use execute(Class, Map)
 Connection getConnection()
          Provides events with access to the connection supporting this transaction.
static Transaction getInstance()
          Provides a new transaction instance to manage your transaction context.
 int getTransactionId()
          Each transaction has a number that helps identify it for debugging purposes.
 int hashCode()
           
static void report()
           
 void rollback()
          Rolls back the transaction and closes this transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Transaction getInstance()
Provides a new transaction instance to manage your transaction context.

Returns:
the transaction for your new transaction context

report

public static void report()

close

public void close()
Closes the transaction. If the transaction has not been committed, it is rolled back.


commit

public void commit()
            throws PersistenceException
Commits the transaction to the database and closes the transaction. The transaction should not be used or referenced after calling this method.

Throws:
PersistenceException - either you are trying to commit to a used up transaction or a database error occurred during the commit

execute

public Map<String,Object> execute(Class<? extends Execution> cls,
                                  Map<String,Object> args)
                           throws PersistenceException
Throws:
PersistenceException

execute

public Map<String,Object> execute(Class<? extends Execution> cls,
                                  Map<String,Object> args,
                                  String dsn)
                           throws PersistenceException
Throws:
PersistenceException

execute

public HashMap<String,Object> execute(Execution event,
                                      Map<String,Object> args)
                               throws PersistenceException
Deprecated. use execute(Class, Map)

Executes the specified event as part of this transaction.

Parameters:
event - the event to execute in this transaction context
args - the values to be used by the event
Returns:
results from the transaction, can be null
Throws:
PersistenceException - an error occurred interacting with the database

getConnection

public Connection getConnection()
Provides events with access to the connection supporting this transaction.

Returns:
the connection supporting this transaction

getTransactionId

public int getTransactionId()
Each transaction has a number that helps identify it for debugging purposes.

Returns:
the identifier for this transaction

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
a unique hash code

rollback

public void rollback()
Rolls back the transaction and closes this transaction. The transaction should no longer be referenced after this point.