public class DatabaseSessionImpl extends AbstractSession implements DatabaseSession
Purpose: Define the implementation for a single user/single connection TopLink session.
Description: The session is the primary interface into TopLink,
the application should do all of its reading and writing of objects through the session.
The session also manages transactions and units of work. The database session is intended
for usage in two-tier client-server applications. Although it could be used in a server
situation, it is limitted to only having a single database connection and only allows
a single open database transaction.
Responsibilities:
- Connecting/disconnecting.
- Reading and writing objects.
- Transaction and unit of work support.
- Identity maps and caching.
,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isLoggedIn
INTERNAL
Indicate if this session is logged in.
|
accessor, broker, commitManager, ejbqlPlaceHolderQueries, eventManager, exceptionHandler, externalTransactionController, identityMapAccessor, integrityChecker, isInProfile, lastDescriptorAccessed, logSessionString, name, numberOfActiveUnitsOfWork, platform, profiler, project, properties, queries, sessionLog, transactionMutex, wasJTSTransactionInternallyStarted| Constructor and Description |
|---|
DatabaseSessionImpl()
INTERNAL:
Create and return a new default database session.
|
DatabaseSessionImpl(Login login)
PUBLIC:
Create and return a new session.
|
DatabaseSessionImpl(Project project)
PUBLIC:
Create and return a new session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDescriptor(ClassDescriptor descriptor)
PUBLIC:
Add the descriptor to the session.
|
void |
addDescriptors(Project project)
PUBLIC:
Add the descriptors to the session from the Project.
|
void |
addDescriptors(java.util.Vector descriptors)
PUBLIC:
Add the descriptors to the session.
|
void |
afterTransaction(boolean committed,
boolean isExternalTransaction)
INTERNAL:
Called after transaction is completed (committed or rolled back)
|
void |
connect()
INTERNAL:
Connect the session only.
|
void |
connect(boolean updatePlatform)
INTERNAL:
Connect the session only.
|
void |
disconnect()
INTERNAL:
Disconnect the accessor only.
|
protected void |
finalize()
INTERNAL:
Logout in case still connected.
|
long |
getConnectedTime()
PUBLIC:
Answer the time that this session got connected.
|
java.util.Map |
getDescriptors()
PUBLIC:
Return all registered descriptors.
|
protected Login |
getReadLogin()
INTERNAL:
Return the login for the read connection.
|
Sequencing |
getSequencing()
INTERNAL:
Return the Sequencing object used by the session.
|
SequencingControl |
getSequencingControl()
PUBLIC:
Return SequencingControl which used for sequencing setup and
customization including management of sequencing preallocation.
|
protected SequencingHome |
getSequencingHome()
INTERNAL:
Return SequencingHome which used to obtain all sequence-related
interfaces for DatabaseSession
|
ServerPlatform |
getServerPlatform()
PUBLIC:
Answer the server platform to handle server specific behaviour for WLS, Oc4j, etc.
|
void |
initializeConnectedTime()
PUBLIC:
Initialize the time that this session got connected.
|
void |
initializeDescriptorIfSessionAlive(ClassDescriptor descriptor)
INTERNAL:
A descriptor may have been added after the session is logged in.
|
void |
initializeDescriptors()
INTERNAL:
Allow each descriptor to initialize any dependancies on this session.
|
void |
initializeDescriptors(java.util.Map descriptors)
INTERNAL:
Allow each descriptor to initialize any dependancies on this session.
|
void |
initializeDescriptors(java.util.Vector descriptors)
INTERNAL:
Allow each descriptor to initialize any dependancies on this session.
|
void |
initializeSequencing()
INTERNAL:
Creates sequencing object
|
boolean |
isDatabaseSession()
INTERNAL:
Return if this session is a database session.
|
void |
login()
PUBLIC:
Connect to the database using the predefined login.
|
void |
login(Login login)
PUBLIC:
Connect to the database using the given login.
|
void |
login(java.lang.String userName,
java.lang.String password)
PUBLIC:
Connect to the database using the given user name and password.
|
void |
loginAndDetectDatasource()
PUBLIC:
Connect to the database using the predefined login.
|
void |
logout()
PUBLIC:
Disconnect from the database.
|
protected void |
postConnectDatasource()
INTERNAL:
This method includes all of the code that is issued after the datasource
is connected to.
|
protected void |
preConnectDatasource()
INTERNAL:
This method includes all of the code that is issued before the datasource
is connected to.
|
protected void |
setSequencingHome(SequencingHome sequencingHome)
INTERNAL:
Set the SequencingHome object used by the session.
|
void |
setServerPlatform(ServerPlatform newServerPlatform)
PUBLIC:
Set the server platform to handle server specific behaviour for WLS, Oc4j, etc
This is not permitted after the session is logged in.
|
void |
writeAllObjects(java.util.Collection domainObjects)
PUBLIC:
Write all of the objects and all of their privately owned parts in the database.
|
void |
writeAllObjects(java.util.Vector domainObjects)
PUBLIC:
Write all of the objects and all of their privately owned parts in the database.
|
acquireNonSynchronizedUnitOfWork, acquireUnitOfWork, addAlias, addEjbqlPlaceHolderQuery, addQuery, addQuery, basicBeginTransaction, basicCommitTransaction, basicRollbackTransaction, beginExternalTransaction, beginTransaction, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, commitTransaction, compareObjects, compareObjectsDontMatch, config, containsQuery, copyObject, copyObject, copyReadOnlyClasses, deleteAllObjects, deleteAllObjects, deleteObject, doesObjectExist, dontLogMessages, endOperationProfile, executeCall, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, fine, finer, finest, getAccessor, getAccessor, getAccessor, getActiveSession, getActiveUnitOfWork, getAliasDescriptors, getAllQueries, getBroker, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getCommitManager, getDatasourceLogin, getDatasourcePlatform, getDefaultReadOnlyClasses, getDescriptor, getDescriptor, getDescriptorForAlias, getEjbqlPlaceHolderQueries, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExecutionSession, getExternalTransactionController, getIdentityMapAccessor, getIdentityMapAccessorInstance, getIntegrityChecker, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParentIdentityMapSession, getParentIdentityMapSession, getPlatform, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getRootSession, getSessionForClass, getSessionLog, getSessionTypeString, getTransactionMutex, handleException, handleSevere, hasBroker, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, hasProperties, incrementProfile, info, initializeIdentityMapAccessor, insertObject, internalExecuteQuery, isBroker, isClassReadOnly, isClassReadOnly, isClientSession, isConnected, isDistributedSession, isInBroker, isInProfile, isInTransaction, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isUnitOfWork, keyFromObject, keyFromObject, log, log, log, log, log, log, log, log, log, log, logMessage, logThrowable, prepareDatabaseQuery, processEJBQLQueries, processEJBQLQueries, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, release, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, rollbackExternalTransaction, rollbackTransaction, setAccessor, setBroker, setCommitManager, setDatasourceLogin, setEventManager, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsInProfile, setLog, setLogin, setLogin, setLogLevel, setName, setNumberOfActiveUnitsOfWork, setProfiler, setProject, setProperties, setProperty, setQueries, setSessionLog, setTransactionMutex, setWasJTSTransactionInternallyStarted, severe, shouldLog, shouldLogMessages, startOperationProfile, toString, unwrapObject, updateObject, updateProfile, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeAllObjects, writeAllObjectsWithChangeSet, writeObject, writesCompletedequals, getClass, hashCode, notify, notifyAll, wait, wait, waitbeginTransaction, commitTransaction, deleteAllObjects, deleteAllObjects, deleteObject, insertObject, isInTransaction, refreshAndLockObject, refreshAndLockObject, rollbackTransaction, setDatasourceLogin, setExternalTransactionController, setLogin, updateObject, writeObjectacquireUnitOfWork, addEjbqlPlaceHolderQuery, addQuery, clearIntegrityChecker, clearProfile, containsQuery, copyObject, copyObject, doesObjectExist, dontLogMessages, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, getActiveSession, getActiveUnitOfWork, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDatasourcePlatform, getDescriptor, getDescriptor, getDescriptorForAlias, getEjbqlPlaceHolderQueries, getEventManager, getExceptionHandler, getExternalTransactionController, getIdentityMapAccessor, getIntegrityChecker, getLog, getLogin, getLogLevel, getLogLevel, getName, getNextSequenceNumberValue, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getSessionLog, handleException, handleSevere, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, isClientSession, isConnected, isDistributedSession, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isUnitOfWork, keyFromObject, log, log, logMessage, logThrowable, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, refreshObject, release, removeProperty, removeQuery, setExceptionHandler, setIntegrityChecker, setLog, setLogLevel, setName, setProfiler, setProperty, setSessionLog, shouldLog, shouldLogMessagesprotected boolean isLoggedIn
public DatabaseSessionImpl()
public DatabaseSessionImpl(Login login)
public DatabaseSessionImpl(Project project)
protected void setSequencingHome(SequencingHome sequencingHome)
protected SequencingHome getSequencingHome()
public SequencingControl getSequencingControl()
getSequencingControl in interface DatabaseSessionpublic Sequencing getSequencing()
getSequencing in class AbstractSessionpublic void initializeSequencing()
public void afterTransaction(boolean committed,
boolean isExternalTransaction)
afterTransaction in class AbstractSessionpublic void addDescriptor(ClassDescriptor descriptor)
addDescriptor in interface DatabaseSessionaddDescriptors(Vector),
addDescriptors(oracle.toplink.essentials.sessions.Project)public void addDescriptors(java.util.Vector descriptors)
addDescriptors in interface DatabaseSessionpublic void addDescriptors(Project project)
addDescriptors in interface DatabaseSessionpublic void connect()
throws DatabaseException
DatabaseExceptionpublic void connect(boolean updatePlatform)
throws DatabaseException
DatabaseExceptionpublic void disconnect()
throws DatabaseException
DatabaseExceptionpublic ServerPlatform getServerPlatform()
getServerPlatform in interface DatabaseSessiongetServerPlatform in class AbstractSessionServerPlatformBasepublic void setServerPlatform(ServerPlatform newServerPlatform)
setServerPlatform in interface DatabaseSessionServerPlatformBaseprotected void finalize()
throws DatabaseException
finalize in class java.lang.ObjectDatabaseExceptionpublic java.util.Map getDescriptors()
getDescriptors in interface SessiongetDescriptors in class AbstractSessionpublic void initializeDescriptorIfSessionAlive(ClassDescriptor descriptor)
public void initializeDescriptors()
public void initializeDescriptors(java.util.Map descriptors)
public void initializeDescriptors(java.util.Vector descriptors)
public boolean isDatabaseSession()
isDatabaseSession in interface SessionisDatabaseSession in class AbstractSessionprotected Login getReadLogin()
public void loginAndDetectDatasource()
throws DatabaseException
DatabaseExceptionpublic void login()
throws DatabaseException
login in interface DatabaseSessionDatabaseExceptionlogin(Login)public void login(java.lang.String userName,
java.lang.String password)
throws DatabaseException
login in interface DatabaseSessionDatabaseExceptionpublic void login(Login login) throws DatabaseException
login in interface DatabaseSessionDatabaseExceptionpublic void logout()
throws DatabaseException
logout in interface DatabaseSessionTopLinkException - if a transaction is active, you must rollback any active transaction before logout.DatabaseException - the database will also raise an error if their is an active transaction,
or a general error occurs.public void initializeConnectedTime()
public long getConnectedTime()
protected void preConnectDatasource()
protected void postConnectDatasource()
public void writeAllObjects(java.util.Collection domainObjects)
throws DatabaseException,
OptimisticLockException
writeAllObjects in interface DatabaseSessionDatabaseException - if an error occurs on the database,
these include constraint violations, security violations and general database erros.OptimisticLockException - if the object's descriptor is using optimistic locking and
the object has been updated or deleted by another user since it was last read.public void writeAllObjects(java.util.Vector domainObjects)
throws DatabaseException,
OptimisticLockException
writeAllObjects in interface DatabaseSessionDatabaseException - if an error occurs on the database,
these include constraint violations, security violations and general database erros.OptimisticLockException - if the object's descriptor is using optimistic locking and
the object has been updated or deleted by another user since it was last read.