Package org.castor.persist
Class GlobalTransactionContext
java.lang.Object
org.castor.persist.AbstractTransactionContext
org.castor.persist.GlobalTransactionContext
- All Implemented Interfaces:
TransactionContext
A transaction context is required in order to perform operations
against the database. The transaction context is mapped to
Transaction for the ODMG API and into
XAResource for 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThe derived class must implement this method and close all the connections used in this transaction.protected voidThe derived class must implement this method and commit all the connections used in this transaction.protected ConnectioncreateConnection(LockEngine engine) protected voidThe 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 Details
-
GlobalTransactionContext
Create a new transaction context.- Parameters:
db- Database instance
-
-
Method Details
-
createConnection
- Specified by:
createConnectionin classAbstractTransactionContext- Throws:
ConnectionFailedException- See Also:
-
commitConnections
The 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:
-
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:
-
closeConnections
The 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:
-