Package org.castor.persist
Class LocalTransactionContext
- java.lang.Object
-
- org.castor.persist.AbstractTransactionContext
-
- org.castor.persist.LocalTransactionContext
-
- All Implemented Interfaces:
TransactionContext
public final class LocalTransactionContext extends AbstractTransactionContext
A transaction context is required in order to perform operations against the database. The transaction context is mapped toTransaction
for the ODMG API and intoXAResource
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 Constructor Description LocalTransactionContext(Database db)
Create a new transaction context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeConnections()
The derived class must implement this method and close all the connections used in this transaction.protected void
commitConnections()
The derived class must implement this method and commit all the connections used in this transaction.protected java.sql.Connection
createConnection(LockEngine engine)
protected void
rollbackConnections()
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
-
LocalTransactionContext
public LocalTransactionContext(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:
createConnection
in classAbstractTransactionContext
- Throws:
ConnectionFailedException
- See Also:
#createConnection(org.exolab.castor.persist.LockEngine)
-
commitConnections
protected void commitConnections() throws TransactionAbortedException
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:
commitConnections
in 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:
rollbackConnections
in classAbstractTransactionContext
- See Also:
AbstractTransactionContext.rollbackConnections()
-
closeConnections
protected void closeConnections() throws TransactionAbortedException
The derived class must implement this method and close all the connections used in this transaction.- Specified by:
closeConnections
in classAbstractTransactionContext
- Throws:
TransactionAbortedException
- The transaction could not close all the connections.- See Also:
AbstractTransactionContext.closeConnections()
-
-