org.pojava.persistence.sql
Class DatabaseTransaction

java.lang.Object
  extended by org.pojava.persistence.sql.DatabaseTransaction
All Implemented Interfaces:
ConnectionSource, Transaction

public class DatabaseTransaction
extends Object
implements Transaction, ConnectionSource

A DatabaseTransaction object coordinates the transactions of multiple connections so that all of them commit or roll back as a collective.

Author:
John Pile

Constructor Summary
DatabaseTransaction()
           
 
Method Summary
 void commit()
          Commit all transactions on all managed connections.
 Connection getConnection(String dataSourceName)
          Obtain a connection, reusing an existing transaction if possible.
 void rollback()
          Rollback all transactions on all managed connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseTransaction

public DatabaseTransaction()
Method Detail

getConnection

public Connection getConnection(String dataSourceName)
                         throws org.pojava.exception.PersistenceException
Obtain a connection, reusing an existing transaction if possible. This is done to reduce the risk of deadlock between two connections within the same transaction.

Specified by:
getConnection in interface ConnectionSource
Returns:
Connection
Throws:
org.pojava.exception.PersistenceException

rollback

public void rollback()
Rollback all transactions on all managed connections.

Specified by:
rollback in interface Transaction

commit

public void commit()
Commit all transactions on all managed connections.

Specified by:
commit in interface Transaction


Copyright © 2011. All Rights Reserved.