Package org.exolab.castor.jdo.engine
Class GlobalDatabaseImpl
java.lang.Object
org.exolab.castor.jdo.engine.AbstractDatabaseImpl
org.exolab.castor.jdo.engine.GlobalDatabaseImpl
- All Implemented Interfaces:
Synchronization,Database
An implementation of the JDO database supporting explicit transaction
demarcation.
- Version:
- $Revision: 8347 $ $Date: 2006-04-10 16:39:24 -0600 (Mon, 10 Apr 2006) $
- Author:
- Werner Guttmann
-
Field Summary
Fields inherited from class org.exolab.castor.jdo.engine.AbstractDatabaseImpl
_autoStore, _callback, _classLoader, _ctx, _dbName, _instanceFactory, _lockTimeout, _scope -
Constructor Summary
ConstructorsConstructorDescriptionGlobalDatabaseImpl(String dbName, int lockTimeout, CallbackInterceptor callback, InstanceFactory instanceFactory, Transaction transaction, ClassLoader classLoader, boolean autoStore, boolean isPoolInUseForGlobalTransactions) Creates an instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionvoidafterCompletion(int status) voidvoidbegin()Begin a new transaction.voidclose()Closes the database.voidcommit()Commits and closes the transaction.protected voidfinalize()Overrides Object.finalize().Gets the underlying JDBC connection.voidrollback()Rolls back and closes the transaction.(package private) voidsetTxMap(TxDatabaseMap txMap) Methods inherited from class org.exolab.castor.jdo.engine.AbstractDatabaseImpl
create, getCacheManager, getClassLoader, getCurrentTransaction, getDatabaseName, getIdentity, getLockEngine, getNamedQuery, getNativeQuery, getOQLQuery, getOQLQuery, getQuery, getScope, getTransaction, isActive, isAutoStore, isClosed, isLocked, isPersistent, load, load, load, loadSynchronizables, lock, registerSynchronizables, remove, setAutoStore, toString, unregisterSynchronizables, update
-
Constructor Details
-
GlobalDatabaseImpl
public GlobalDatabaseImpl(String dbName, int lockTimeout, CallbackInterceptor callback, InstanceFactory instanceFactory, Transaction transaction, ClassLoader classLoader, boolean autoStore, boolean isPoolInUseForGlobalTransactions) throws DatabaseNotFoundException Creates an instance of this class.- Parameters:
dbName- Database name.lockTimeout- Lock timeout.callback- Callback interceptors.instanceFactory- Instance factory to use.transaction- Current XA transaction.classLoader- Current class loader.autoStore- True if auto-storing is enabled.isPoolInUseForGlobalTransactions- True if Database instanced should be cached.- Throws:
DatabaseNotFoundException- If the specified database cannot be found.
-
-
Method Details
-
close
Description copied from class:AbstractDatabaseImplCloses the database. If a client transaction is in progress the transaction will be rolled back and an exception thrown. If an app-server transaction is in progress, the transaction will commit/rollback when triggered by the application server.- Specified by:
closein interfaceDatabase- Specified by:
closein classAbstractDatabaseImpl- Throws:
PersistenceException- An error occured while attempting to close the database
-
finalize
Overrides Object.finalize(). Outputs a warning message to the logs if the current DatabaseImpl instance still has valid scope. In this condition - a condition that ideally should not occur at all - we close the instance as well to free up resources. -
begin
Description copied from class:AbstractDatabaseImplBegin a new transaction. A transaction must be open in order to query and persist objects.- Specified by:
beginin interfaceDatabase- Specified by:
beginin classAbstractDatabaseImpl- Throws:
PersistenceException- A transaction is already open on this database, or an error reported by the persistence engine
-
commit
Description copied from class:AbstractDatabaseImplCommits and closes the transaction. All changes made to persistent objects during the transaction are made persistent; objects created during the transaction are made durable; and, objects removed during the transaction are removed from the database.In other words, any modifications to any data objects which are queried/loaded/created/update to this database is automatically stored to the database and visible to subsequence transactions. (ie. update is solely used for long transaction support and should not be called for any data object queried/loaded/created in the this transaction.)
If the transaction cannot commit, the entire transaction rolls back and a
TransactionAbortedExceptionexception is thrown.After this method returns, the transaction is closed and all persistent objects are transient. Using
Database.begin()to open a new transaction will not restore objects to their persistent stage.- Specified by:
commitin interfaceDatabase- Specified by:
commitin classAbstractDatabaseImpl- Throws:
TransactionNotInProgressException- Method called while transaction is not in progressTransactionAbortedException- The transaction cannot commit and has been rolled back
-
rollback
Description copied from class:AbstractDatabaseImplRolls back and closes the transaction. All changes made to persistent objects during the transaction are lost, objects created during the transaction are not made durable and objects removed during the transaction continue to exist.- Specified by:
rollbackin interfaceDatabase- Specified by:
rollbackin classAbstractDatabaseImpl- Throws:
TransactionNotInProgressException- Method called while transaction is not in progress
-
beforeCompletion
public void beforeCompletion()- Specified by:
beforeCompletionin interfaceSynchronization
-
afterCompletion
public void afterCompletion(int status) - Specified by:
afterCompletionin interfaceSynchronization
-
setTxMap
-
getJdbcConnection
Description copied from class:AbstractDatabaseImplGets the underlying JDBC connection. This is for advanced use only. Please make sure that you never close this Connection instance, as it will be closed by Castor.- Specified by:
getJdbcConnectionin interfaceDatabase- Specified by:
getJdbcConnectionin classAbstractDatabaseImpl- Returns:
- the underlying JDBC connection, if present; otherwise null
- Throws:
PersistenceException- If the underlying JDBC connection cannot be obtained.
-