Package org.castor.persist
Class GlobalTransactionContext
- java.lang.Object
-
- org.castor.persist.AbstractTransactionContext
-
- org.castor.persist.GlobalTransactionContext
-
- All Implemented Interfaces:
TransactionContext
public final class GlobalTransactionContext extends AbstractTransactionContext
A transaction context is required in order to perform operations against the database. The transaction context is mapped toTransactionfor the ODMG API and intoXAResourcefor XA databases. The only way to begin a new transaction is through the creation of a new transaction context. All database access must be performed through a transaction context.- Since:
- 1.0
- Version:
- $Revision: 8111 $ $Date: 2006-04-13 10:49:49 -0600 (Thu, 13 Apr 2006) $
- Author:
- Ralf Joachim
-
-
Constructor Summary
Constructors Constructor Description GlobalTransactionContext(Database db)Create a new transaction context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseConnections()The derived class must implement this method and close all the connections used in this transaction.protected voidcommitConnections()The derived class must implement this method and commit all the connections used in this transaction.protected java.sql.ConnectioncreateConnection(LockEngine engine)protected voidrollbackConnections()The derived class must implement this method and rollback all the connections used in this transaction.-
Methods inherited from class org.castor.persist.AbstractTransactionContext
addTxSynchronizable, clearConnections, close, commit, connectionsIterator, create, delete, expireCache, fetch, getClassLoader, getConnection, getConnectionInfo, getDatabase, getInstanceFactory, getLockTimeout, getNamedNativeQuery, getNamedQuery, getStatus, getTransactionTimeout, getWaitOnLock, isAutoStore, isCached, isCreated, isDeleted, isDeletedByOID, isDepended, isLocked, isOpen, isPersistent, isReadOnly, isRecorded, isUpdateCacheNeeded, isUpdatePersistNeeded, iterateReadWriteObjectsInTransaction, load, load, markCreate, markModified, markUpdate, prepare, query, removeTxSynchronizable, rollback, setAutoStore, setCallback, setInstanceFactory, setLockTimeout, setStatus, setTransactionTimeout, setWaitOnLock, trackObject, untrackObject, update, writeLock
-
-
-
-
Constructor Detail
-
GlobalTransactionContext
public GlobalTransactionContext(Database db)
Create a new transaction context.- Parameters:
db- Database instance
-
-
Method Detail
-
createConnection
protected java.sql.Connection createConnection(LockEngine engine) throws ConnectionFailedException
- Specified by:
createConnectionin classAbstractTransactionContext- Throws:
ConnectionFailedException- See Also:
#createConnection(org.exolab.castor.persist.LockEngine)
-
commitConnections
protected void commitConnections() throws TransactionAbortedExceptionThe derived class must implement this method and commit all the connections used in this transaction. If the transaction could not commit fully or partially, this method will throw anTransactionAbortedException, causing a rollback to occur as the next step.- Specified by:
commitConnectionsin classAbstractTransactionContext- Throws:
TransactionAbortedException- The transaction could not commit fully or partially and should be rolled back.- See Also:
AbstractTransactionContext.commitConnections()
-
rollbackConnections
protected void rollbackConnections()
The derived class must implement this method and rollback all the connections used in this transaction. The connections may be closed, as they will not be reused in this transaction. This operation is guaranteed to succeed.- Specified by:
rollbackConnectionsin classAbstractTransactionContext- See Also:
AbstractTransactionContext.rollbackConnections()
-
closeConnections
protected void closeConnections() throws TransactionAbortedExceptionThe derived class must implement this method and close all the connections used in this transaction.- Specified by:
closeConnectionsin classAbstractTransactionContext- Throws:
TransactionAbortedException- The transaction could not close all the connections.- See Also:
AbstractTransactionContext.closeConnections()
-
-