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 FormModifier 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(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.
|
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(Map descriptors)
INTERNAL:
Allow each descriptor to initialize any dependancies on this session.
|
void |
initializeDescriptors(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(String userName,
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(Collection domainObjects)
PUBLIC:
Write all of the objects and all of their privately owned parts in the database.
|
void |
writeAllObjects(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, writesCompleted
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
beginTransaction, commitTransaction, deleteAllObjects, deleteAllObjects, deleteObject, insertObject, isInTransaction, refreshAndLockObject, refreshAndLockObject, rollbackTransaction, setDatasourceLogin, setExternalTransactionController, setLogin, updateObject, writeObject
acquireUnitOfWork, 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, shouldLogMessages
protected 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 DatabaseSession
public Sequencing getSequencing()
getSequencing
in class AbstractSession
public void initializeSequencing()
public void afterTransaction(boolean committed, boolean isExternalTransaction)
afterTransaction
in class AbstractSession
public void addDescriptor(ClassDescriptor descriptor)
addDescriptor
in interface DatabaseSession
addDescriptors(Vector)
,
addDescriptors(oracle.toplink.essentials.sessions.Project)
public void addDescriptors(Vector descriptors)
addDescriptors
in interface DatabaseSession
public void addDescriptors(Project project)
addDescriptors
in interface DatabaseSession
public void connect() throws DatabaseException
DatabaseException
public void connect(boolean updatePlatform) throws DatabaseException
DatabaseException
public void disconnect() throws DatabaseException
DatabaseException
public ServerPlatform getServerPlatform()
getServerPlatform
in interface DatabaseSession
getServerPlatform
in class AbstractSession
ServerPlatformBase
public void setServerPlatform(ServerPlatform newServerPlatform)
setServerPlatform
in interface DatabaseSession
ServerPlatformBase
protected void finalize() throws DatabaseException
finalize
in class Object
DatabaseException
public Map getDescriptors()
getDescriptors
in interface Session
getDescriptors
in class AbstractSession
public void initializeDescriptorIfSessionAlive(ClassDescriptor descriptor)
public void initializeDescriptors()
public void initializeDescriptors(Map descriptors)
public void initializeDescriptors(Vector descriptors)
public boolean isDatabaseSession()
isDatabaseSession
in interface Session
isDatabaseSession
in class AbstractSession
protected Login getReadLogin()
public void loginAndDetectDatasource() throws DatabaseException
DatabaseException
public void login() throws DatabaseException
login
in interface DatabaseSession
DatabaseException
login(Login)
public void login(String userName, String password) throws DatabaseException
login
in interface DatabaseSession
DatabaseException
public void login(Login login) throws DatabaseException
login
in interface DatabaseSession
DatabaseException
public void logout() throws DatabaseException
logout
in interface DatabaseSession
TopLinkException
- 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(Collection domainObjects) throws DatabaseException, OptimisticLockException
writeAllObjects
in interface DatabaseSession
DatabaseException
- 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(Vector domainObjects) throws DatabaseException, OptimisticLockException
writeAllObjects
in interface DatabaseSession
DatabaseException
- 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.Copyright © 2023. All rights reserved.