public class DatabaseSessionImpl extends AbstractSession implements DatabaseSession
Purpose: Define the implementation for a single user/single connection EclipseLink session.
Description: The session is the primary interface into EclipseLink,
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 limited 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 FormLOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING
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(java.util.Collection descriptors)
PUBLIC:
Add the descriptors to the session.
|
void |
addDescriptors(Project project)
PUBLIC:
Add the descriptors to the session from the Project.
|
void |
addDescriptorsToSequencing(java.util.Collection descriptors)
INTERNAL:
If sequencing is connected then initializes sequences referenced by the passed descriptors,
otherwise connects sequencing.
|
void |
addSequence(Sequence sequence)
PUBLIC:
Add the sequence to the session.
|
void |
connect()
INTERNAL:
Connect the session only.
|
void |
disconnect()
INTERNAL:
Disconnect the accessor only.
|
long |
getConnectedTime()
PUBLIC:
Answer the time that this session got connected.
|
DatabaseEventListener |
getDatabaseEventListener()
Return the database event listener, this allows database events to invalidate the cache.
|
Platform |
getDatasourcePlatform()
INTERNAL:
Return the database platform currently connected to.
|
DatabasePlatform |
getPlatform()
INTERNAL:
Return the database platform currently connected to.
|
Platform |
getPlatform(java.lang.Class domainClass)
INTERNAL:
Return the database platform currently connected to
for specified class.
|
Sequencing |
getSequencing()
PUBLIC:
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.
|
ServerPlatform |
getServerPlatform()
PUBLIC:
Answer the server platform to handle server specific behavior for WLS, Oc4j, etc.
|
SessionTuner |
getTuner()
Return the tuner used to tune the configuration of this session.
|
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 dependencies on this session.
|
void |
initializeDescriptors(java.util.Collection descriptors) |
void |
initializeDescriptors(java.util.Collection descriptors,
boolean shouldInitializeSequencing) |
void |
initializeDescriptors(java.util.Map descriptors)
INTERNAL:
Allow each descriptor to initialize any dependencies on this session.
|
void |
initializeDescriptors(java.util.Map descriptors,
boolean shouldInitializeSequencing)
INTERNAL:
Allow each descriptor to initialize any dependencies on this session.
|
void |
initializeSequencing()
INTERNAL:
Creates sequencing object
|
boolean |
isDatabaseSession()
INTERNAL:
Return if this session is a database session.
|
boolean |
isLoggedIn()
INTERNAL:
Return if the session was logged in.
|
boolean |
isProtectedSession()
PUBLIC:
Returns true if Protected Entities should be built within this session
|
boolean |
isSequencingCallbackRequired()
INTERNAL:
Indicates whether SequencingCallback is required.
|
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.
|
void |
postLogin()
INTERNAL:
Rise postLogin event.
|
void |
releaseJTSConnection()
INTERNAL:
Called in the end of beforeCompletion of external transaction synchronization listener.
|
java.lang.Object |
retryQuery(DatabaseQuery query,
AbstractRecord row,
DatabaseException databaseException,
int retryCount,
AbstractSession executionSession)
INTERNAL:
A query execution failed due to an invalid query.
|
void |
setDatabaseEventListener(DatabaseEventListener databaseEventListener)
PUBLIC:
Set the database event listener, this allows database events to invalidate the cache.
|
void |
setDatasourceAndInitialize()
INTERNAL:
Issue any pre connect and post connect without an actual connection to
the database.
|
void |
setServerPlatform(ServerPlatform newServerPlatform)
PUBLIC:
Set the server platform to handle server specific behavior for WLS, Oc4j, etc
This is not permitted after the session is logged in.
|
void |
setTuner(SessionTuner tuner)
Set the tuner used to tune the configuration of this session.
|
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.
|
acquireHistoricalSession, acquireNonSynchronizedUnitOfWork, acquireNonSynchronizedUnitOfWork, acquireRepeatableWriteUnitOfWork, acquireUnitOfWork, acquireUnitOfWork, addAlias, addJPAQuery, addJPATablePerTenantQuery, addMultitenantContextProperty, addQuery, addQuery, addStaticMetamodelClass, basicExecuteCall, beginExternalTransaction, beginTransaction, checkAndRefreshInvalidObject, cleanUpEntityListenerInjectionManager, clearDescriptors, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, commitTransaction, compareObjects, compareObjectsDontMatch, config, containsQuery, copy, copy, copyDescriptorNamedQueries, copyDescriptorsFromProject, copyInternal, copyObject, copyObject, copyReadOnlyClasses, createCloneQueryValueHolder, createCloneTransformationValueHolder, createEntityListenerInjectionManager, createProtectedInstanceFromCachedData, deferEvent, deleteAllObjects, deleteAllObjects, deleteObject, doesObjectExist, dontLogMessages, endOperationProfile, endOperationProfile, executeCall, executeDeferredEvents, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, fine, finer, finest, getAccessor, getAccessors, getAccessors, getActiveCommandThreads, getActiveSession, getActiveUnitOfWork, getAliasDescriptors, getAllQueries, getAsOfClause, getAttributeGroups, getBroker, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getCommandManager, getCommitManager, getDatasourceLogin, getDefaultReadOnlyClasses, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEntityListenerInjectionManager, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExecutionSession, getExternalTransactionController, getId, getIdentityMapAccessor, getIdentityMapAccessorInstance, getIntegrityChecker, getJPAQueries, getJPATablePerTenantQueries, getLoader, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getMappedSuperclass, getMultitenantContextProperties, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParent, getParentIdentityMapSession, getParentIdentityMapSession, getParentIdentityMapSession, getPartitioningPolicy, getPessimisticLockTimeoutDefault, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getQuery, getQuery, getQueryBuilder, getQueryTimeoutDefault, getRefreshMetadataListener, getRootSession, getSerializer, getSessionForClass, getSessionForName, getSessionLog, getSessionTypeString, getStaticMetamodelClass, getTablePerTenantDescriptors, getTablePerTenantQueries, getTransactionMutex, handleException, handleSevere, hasBroker, hasCommitManager, hasDescriptor, hasEventManager, hasExceptionHandler, hasExternalTransactionController, hasProperties, hasTablePerTenantDescriptors, hasTablePerTenantQueries, incrementProfile, incrementProfile, info, initializeIdentityMapAccessor, insertObject, internalExecuteQuery, isBroker, isClassReadOnly, isClassReadOnly, isClientSession, isConcurrent, isConnected, isConsideredInvalid, isDistributedSession, isExclusiveConnectionRequired, isExclusiveIsolatedClientSession, isFinalizersEnabled, isHistoricalSession, isInBroker, isInProfile, isInTransaction, isIsolatedClientSession, isJPAQueriesProcessed, isLoggingOff, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isSynchronized, isUnitOfWork, keyFromObject, keyFromObject, load, load, log, log, log, log, log, log, log, log, log, log, logMessage, logMessage, logThrowable, postAcquireConnection, prepareDatabaseQuery, preReleaseConnection, priviledgedExecuteNonSelectingCall, priviledgedExecuteSelectingCall, processCommand, processJPAQueries, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, registerFinalizer, release, releaseConnectionAfterCall, releaseReadConnection, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, retrieveCacheKey, retryTransaction, rollbackTransaction, setAccessor, setBroker, setCommandManager, setCommitManager, setDatasourceLogin, setDefaultReferenceMode, setEntityListenerInjectionManager, setEventManager, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsConcurrent, setIsFinalizersEnabled, setIsInBroker, setIsInProfile, setJPAQueriesProcessed, setLog, setLoggingOff, setLogin, setLogin, setLogLevel, setName, setPartitioningPolicy, setPessimisticLockTimeoutDefault, setProfiler, setProject, setProperties, setProperty, setQueries, setQueryBuilder, setQueryTimeoutDefault, setRefreshMetadataListener, setSerializer, setSessionLog, setShouldOptimizeResultSetAccess, setShouldPropagateChanges, setSynchronized, setTolerateInvalidJPQL, setWasJTSTransactionInternallyStarted, severe, shouldDisplayData, shouldLog, shouldLogMessages, shouldLogMessages, shouldOptimizeResultSetAccess, shouldPropagateChanges, shouldTolerateInvalidJPQL, startOperationProfile, startOperationProfile, toString, unwrapObject, updateObject, updateProfile, updateTablePerTenantDescriptors, validateCache, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeObject, writesCompleted
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
beginTransaction, commitTransaction, deleteAllObjects, deleteObject, getCommandManager, insertObject, isInTransaction, refreshAndLockObject, refreshAndLockObject, rollbackTransaction, setCommandManager, setDatasourceLogin, setExternalTransactionController, setLogin, setShouldPropagateChanges, shouldPropagateChanges, updateObject, writeObject
acquireHistoricalSession, acquireUnitOfWork, acquireUnitOfWork, addJPAQuery, addQuery, clearIntegrityChecker, clearProfile, containsQuery, copy, copy, copyObject, copyObject, doesObjectExist, dontLogMessages, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, getActiveSession, getActiveUnitOfWork, getAsOfClause, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEventManager, getExceptionHandler, getExternalTransactionController, getId, getIdentityMapAccessor, getIntegrityChecker, getJPAQueries, getLog, getLogin, getLogLevel, getLogLevel, getName, getNextSequenceNumberValue, getPartitioningPolicy, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getSerializer, getSessionLog, handleException, handleSevere, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, isClientSession, isConnected, isDistributedSession, isFinalizersEnabled, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isUnitOfWork, keyFromObject, log, logMessage, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, refreshObject, release, removeProperty, removeQuery, setDefaultReferenceMode, setExceptionHandler, setIntegrityChecker, setIsFinalizersEnabled, setLog, setLogLevel, setName, setPartitioningPolicy, setProfiler, setProperty, setQueryTimeoutDefault, setSerializer, setSessionLog, shouldLog, shouldLogMessages, validateCache
public DatabaseSessionImpl()
public DatabaseSessionImpl(Login login)
public DatabaseSessionImpl(Project project)
public boolean isLoggedIn()
public DatabaseEventListener getDatabaseEventListener()
getDatabaseEventListener
in interface DatabaseSession
public void setDatabaseEventListener(DatabaseEventListener databaseEventListener)
setDatabaseEventListener
in interface DatabaseSession
public void setDatasourceAndInitialize() throws DatabaseException
DatabaseException
public SequencingControl getSequencingControl()
getSequencingControl
in interface DatabaseSession
public Sequencing getSequencing()
getSequencing
in class AbstractSession
public boolean isSequencingCallbackRequired()
public void initializeSequencing()
public void addDescriptorsToSequencing(java.util.Collection descriptors)
public void releaseJTSConnection()
releaseJTSConnection
in class AbstractSession
public void addDescriptor(ClassDescriptor descriptor)
addDescriptor
in interface DatabaseSession
#addDescriptors(Vector)
,
addDescriptors(org.eclipse.persistence.sessions.Project)
public void addDescriptors(java.util.Collection descriptors)
addDescriptors
in interface DatabaseSession
public void addDescriptors(Project project)
addDescriptors
in interface DatabaseSession
public void addSequence(Sequence sequence)
addSequence
in interface DatabaseSession
#addSequences(Collection)
public void connect() throws DatabaseException
DatabaseException
public void disconnect() throws DatabaseException
DatabaseException
public ServerPlatform getServerPlatform()
getServerPlatform
in interface DatabaseSession
getServerPlatform
in interface Session
getServerPlatform
in class AbstractSession
ServerPlatformBase
public void setServerPlatform(ServerPlatform newServerPlatform)
setServerPlatform
in interface DatabaseSession
ServerPlatformBase
public DatabasePlatform getPlatform()
getPlatform
in interface Session
getPlatform
in class AbstractSession
public Platform getDatasourcePlatform()
getDatasourcePlatform
in interface CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
getDatasourcePlatform
in interface Session
getDatasourcePlatform
in class AbstractSession
public Platform getPlatform(java.lang.Class domainClass)
getPlatform
in class AbstractSession
public void initializeDescriptorIfSessionAlive(ClassDescriptor descriptor)
public void initializeDescriptors()
public void initializeDescriptors(java.util.Map descriptors)
public void initializeDescriptors(java.util.Collection descriptors)
public void initializeDescriptors(java.util.Map descriptors, boolean shouldInitializeSequencing)
public void initializeDescriptors(java.util.Collection descriptors, boolean shouldInitializeSequencing)
public boolean isDatabaseSession()
isDatabaseSession
in interface Session
isDatabaseSession
in class AbstractSession
public boolean isProtectedSession()
isProtectedSession
in class AbstractSession
public void loginAndDetectDatasource() throws DatabaseException
DatabaseException
public void login() throws DatabaseException
login
in interface DatabaseSession
DatabaseException
login(Login)
public void postLogin()
public void login(java.lang.String userName, java.lang.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
EclipseLinkException
- 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()
public void writeAllObjects(java.util.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 errors.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
DatabaseException
- if an error occurs on the database,
these include constraint violations, security violations and general database errors.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 java.lang.Object retryQuery(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession)
retryQuery
in class AbstractSession
public SessionTuner getTuner()
public void setTuner(SessionTuner tuner)
EclipseLink 2.6.3, "build v20160428-59c81c5" API Reference