Class DatabaseSessionImpl
- java.lang.Object
-
- org.eclipse.persistence.internal.core.sessions.CoreAbstractSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
-
- org.eclipse.persistence.internal.sessions.AbstractSession
-
- org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>,CommandProcessor,DatabaseSession,Session
- Direct Known Subclasses:
DistributedSession,ServerSession,SessionBroker
public class DatabaseSessionImpl extends AbstractSession implements DatabaseSession
Implementation of org.eclipse.persistence.sessions.DatabaseSession The public interface should be used.- See Also:
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 Form
-
-
Field Summary
Fields Modifier and Type Field Description protected longconnectedTimeINTERNAL: connectedTime indicates the exact time this session was logged in.protected DatabaseEventListenerdatabaseEventListenerDatabase event listener, this allows database events to invalidate the cache.protected booleanisLoggedInINTERNAL Indicate if this session is logged in.protected SequencingHomesequencingHomeINTERNAL: sequencingHome for this session.protected ServerPlatformserverPlatformUsed to store the server platform that handles server-specific functionality for Oc4j, WLS, etc.protected SessionTunertunerStores the tuner used to tune the configuration of this session.-
Fields inherited from class org.eclipse.persistence.internal.sessions.AbstractSession
accessors, activeCommandThreads, attributeGroups, broker, commandManager, commitManager, defaultReferenceMode, deferredEvents, descriptors, eventManager, exceptionHandler, externalTransactionController, identityMapAccessor, injectionManager, integrityChecker, isConcurrent, isExecutingEvents, isFinalizersEnabled, isInBroker, isInProfile, isLoggingOff, isSynchronized, jpaQueriesProcessed, lastDescriptorAccessed, logSessionString, metadatalistener, multitenantContextProperties, name, numberOfActiveUnitsOfWork, objectsLockedForClone, partitioningPolicy, pessimisticLockTimeoutDefault, pessimisticLockTimeoutUnitDefault, platform, profiler, project, properties, queries, queryBuilder, queryTimeoutDefault, queryTimeoutUnitDefault, serializer, sessionLog, shouldCheckWriteLock, shouldOptimizeResultSetAccess, shouldPropagateChanges, staticMetamodelClasses, tablePerTenantDescriptors, tablePerTenantQueries, tolerateInvalidJPQL, transactionMutex, wasJTSTransactionInternallyStarted
-
Fields inherited from interface org.eclipse.persistence.sessions.coordination.CommandProcessor
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDescriptor(ClassDescriptor descriptor)PUBLIC: Add the descriptor to the session.voidaddDescriptors(java.util.Collection descriptors)PUBLIC: Add the descriptors to the session.voidaddDescriptors(Project project)PUBLIC: Add the descriptors to the session from the Project.voidaddDescriptorsToSequencing(java.util.Collection descriptors)INTERNAL: If sequencing is connected then initializes sequences referenced by the passed descriptors, otherwise connects sequencing.voidaddSequence(Sequence sequence)PUBLIC: Add the sequence to the session.voidconnect()INTERNAL: Connect the session only.voiddisconnect()INTERNAL: Disconnect the accessor only.protected voidfinalize()INTERNAL: Logout in case still connected.longgetConnectedTime()PUBLIC: Answer the time that this session got connected.DatabaseEventListenergetDatabaseEventListener()Return the database event listener, this allows database events to invalidate the cache.PlatformgetDatasourcePlatform()INTERNAL: Return the database platform currently connected to.DatabasePlatformgetPlatform()INTERNAL: Return the database platform currently connected to.PlatformgetPlatform(java.lang.Class domainClass)INTERNAL: Return the database platform currently connected to for specified class.protected LogingetReadLogin()INTERNAL: Return the login for the read connection.SequencinggetSequencing()PUBLIC: Return the Sequencing object used by the session.SequencingControlgetSequencingControl()PUBLIC: Return SequencingControl which used for sequencing setup and customization including management of sequencing preallocation.protected SequencingHomegetSequencingHome()INTERNAL: Return SequencingHome which used to obtain all sequence-related interfaces for DatabaseSessionServerPlatformgetServerPlatform()PUBLIC: Answer the server platform to handle server specific behavior for WLS, Oc4j, etc.SessionTunergetTuner()Return the tuner used to tune the configuration of this session.voidinitializeConnectedTime()PUBLIC: Initialize the time that this session got connected.voidinitializeDescriptorIfSessionAlive(ClassDescriptor descriptor)INTERNAL: A descriptor may have been added after the session is logged in.voidinitializeDescriptors()INTERNAL: Allow each descriptor to initialize any dependencies on this session.voidinitializeDescriptors(java.util.Collection descriptors)voidinitializeDescriptors(java.util.Collection descriptors, boolean shouldInitializeSequencing)voidinitializeDescriptors(java.util.Map descriptors)INTERNAL: Allow each descriptor to initialize any dependencies on this session.voidinitializeDescriptors(java.util.Map descriptors, boolean shouldInitializeSequencing)INTERNAL: Allow each descriptor to initialize any dependencies on this session.voidinitializeSequencing()INTERNAL: Creates sequencing objectbooleanisDatabaseSession()INTERNAL: Return if this session is a database session.booleanisLoggedIn()INTERNAL: Return if the session was logged in.booleanisProtectedSession()PUBLIC: Returns true if Protected Entities should be built within this sessionbooleanisSequencingCallbackRequired()INTERNAL: Indicates whether SequencingCallback is required.voidlogin()PUBLIC: Connect to the database using the predefined login.voidlogin(java.lang.String userName, java.lang.String password)PUBLIC: Connect to the database using the given user name and password.voidlogin(Login login)PUBLIC: Connect to the database using the given login.voidloginAndDetectDatasource()PUBLIC: Connect to the database using the predefined login.voidlogout()PUBLIC: Disconnect from the database.protected voidpostConnectDatasource()INTERNAL: This method includes all of the code that is issued after the datasource is connected to.voidpostLogin()INTERNAL: Rise postLogin event.protected voidpreConnectDatasource()INTERNAL: This method includes all of the code that is issued before the datasource is connected to.voidreleaseJTSConnection()INTERNAL: Called in the end of beforeCompletion of external transaction synchronization listener.java.lang.ObjectretryQuery(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession)INTERNAL: A query execution failed due to an invalid query.voidsetDatabaseEventListener(DatabaseEventListener databaseEventListener)PUBLIC: Set the database event listener, this allows database events to invalidate the cache.voidsetDatasourceAndInitialize()INTERNAL: Issue any pre connect and post connect without an actual connection to the database.protected voidsetOrDetectDatasource(boolean throwException)INTERNAL: Will set the platform from specified schema generation properties or by detecting it through the connection (if one is available).protected voidsetSequencingHome(SequencingHome sequencingHome)INTERNAL: Set the SequencingHome object used by the session.voidsetServerPlatform(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.voidsetTuner(SessionTuner tuner)Set the tuner used to tune the configuration of this session.voidwriteAllObjects(java.util.Collection domainObjects)PUBLIC: Write all of the objects and all of their privately owned parts in the database.voidwriteAllObjects(java.util.Vector domainObjects)PUBLIC: Write all of the objects and all of their privately owned parts in the database.-
Methods inherited from class org.eclipse.persistence.internal.sessions.AbstractSession
acquireHistoricalSession, acquireNonSynchronizedUnitOfWork, acquireNonSynchronizedUnitOfWork, acquireRepeatableWriteUnitOfWork, acquireUnitOfWork, acquireUnitOfWork, addAlias, addJPAQuery, addJPATablePerTenantQuery, addMultitenantContextProperty, addQuery, addQuery, addQuery, addStaticMetamodelClass, addTablePerTenantDescriptor, addTablePerTenantQuery, basicBeginTransaction, basicBeginTransaction, basicCommitTransaction, basicExecuteCall, basicRollbackTransaction, beginExternalTransaction, beginTransaction, buildDefaultQueryBuilder, checkAndRefreshInvalidObject, checkHierarchyForDescriptor, cleanUpInjectionManager, clearDescriptors, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, commitTransaction, compareObjects, compareObjectsDontMatch, config, containsQuery, copy, copy, copyDescriptorNamedQueries, copyDescriptorsFromProject, copyInternal, copyObject, copyObject, copyReadOnlyClasses, createCloneQueryValueHolder, createCloneTransformationValueHolder, createInjectionManager, 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, getCacheKeyFromTargetSessionForMerge, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getCommandManager, getCommitManager, getDatasourceLogin, getDefaultReadOnlyClasses, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExecutionSession, getExternalTransactionController, getId, getIdentityMapAccessor, getIdentityMapAccessorInstance, getInjectionManager, getIntegrityChecker, getJPAQueries, getJPATablePerTenantQueries, getLoader, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getMappedSuperclass, getMultitenantContextProperties, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParent, getParentIdentityMapSession, getParentIdentityMapSession, getParentIdentityMapSession, getPartitioningPolicy, getPessimisticLockTimeoutDefault, getPessimisticLockTimeoutUnitDefault, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getQuery, getQuery, getQueryBuilder, getQueryTimeoutDefault, getQueryTimeoutUnitDefault, 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, processJPAQuery, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, registerFinalizer, release, releaseConnectionAfterCall, releaseReadConnection, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, retrieveCacheKey, retryTransaction, rollbackExternalTransaction, rollbackTransaction, setAccessor, setBroker, setCommandManager, setCommitManager, setDatasourceLogin, setDefaultReferenceMode, setEventManager, setExceptionHandler, setExternalTransactionController, setInjectionManager, setIntegrityChecker, setIsConcurrent, setIsFinalizersEnabled, setIsInBroker, setIsInProfile, setJPAQueriesProcessed, setLog, setLoggingOff, setLogin, setLogin, setLogLevel, setName, setNumberOfActiveUnitsOfWork, setPartitioningPolicy, setPessimisticLockTimeoutDefault, setPessimisticLockTimeoutUnitDefault, setProfiler, setProject, setProperties, setProperty, setQueries, setQueryBuilder, setQueryTimeoutDefault, setQueryTimeoutUnitDefault, setRefreshMetadataListener, setSerializer, setSessionLog, setShouldOptimizeResultSetAccess, setShouldPropagateChanges, setSynchronized, setTolerateInvalidJPQL, setTransactionMutex, setWasJTSTransactionInternallyStarted, severe, shouldDisplayData, shouldLog, shouldLogMessages, shouldLogMessages, shouldOptimizeResultSetAccess, shouldPropagateChanges, shouldTolerateInvalidJPQL, startOperationProfile, startOperationProfile, toString, unwrapObject, updateObject, updateProfile, updateTablePerTenantDescriptors, validateCache, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeAllObjectsWithChangeSet, writeObject, writesCompleted
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.sessions.DatabaseSession
beginTransaction, commitTransaction, deleteAllObjects, deleteObject, getCommandManager, insertObject, isInTransaction, refreshAndLockObject, refreshAndLockObject, rollbackTransaction, setCommandManager, setDatasourceLogin, setExternalTransactionController, setLogin, setShouldPropagateChanges, shouldPropagateChanges, updateObject, writeObject
-
Methods inherited from interface org.eclipse.persistence.sessions.Session
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, setQueryTimeoutUnitDefault, setSerializer, setSessionLog, shouldLog, shouldLogMessages, validateCache
-
-
-
-
Field Detail
-
databaseEventListener
protected DatabaseEventListener databaseEventListener
Database event listener, this allows database events to invalidate the cache.
-
sequencingHome
protected SequencingHome sequencingHome
INTERNAL: sequencingHome for this session.
-
serverPlatform
protected ServerPlatform serverPlatform
Used to store the server platform that handles server-specific functionality for Oc4j, WLS, etc.
-
tuner
protected SessionTuner tuner
Stores the tuner used to tune the configuration of this session.
-
connectedTime
protected long connectedTime
INTERNAL: connectedTime indicates the exact time this session was logged in.
-
isLoggedIn
protected volatile boolean isLoggedIn
INTERNAL Indicate if this session is logged in.
-
-
Constructor Detail
-
DatabaseSessionImpl
public DatabaseSessionImpl()
INTERNAL: Create and return a new default database session. Used for EJB SessionManager to instantiate a database session
-
DatabaseSessionImpl
public DatabaseSessionImpl(Login login)
PUBLIC: Create and return a new session. By giving the login information on creation this allows the session to initialize itself to the platform given in the login. This constructor does not return a connected session. To connect the session to the database login() must be sent to it. The login(userName, password) method may also be used to connect the session, this allows for the user name and password to be given at login but for the other database information to be provided when the session is created.
-
DatabaseSessionImpl
public DatabaseSessionImpl(Project project)
PUBLIC: Create and return a new session. This constructor does not return a connected session. To connect the session to the database login() must be sent to it. The login(userName, password) method may also be used to connect the session, this allows for the user name and password to be given at login but for the other database information to be provided when the session is created.
-
-
Method Detail
-
setSequencingHome
protected void setSequencingHome(SequencingHome sequencingHome)
INTERNAL: Set the SequencingHome object used by the session.
-
getSequencingHome
protected SequencingHome getSequencingHome()
INTERNAL: Return SequencingHome which used to obtain all sequence-related interfaces for DatabaseSession
-
isLoggedIn
public boolean isLoggedIn()
INTERNAL: Return if the session was logged in. This may slight differ to isConnected which asks the JDBC Connection if it is connected.
-
getDatabaseEventListener
public DatabaseEventListener getDatabaseEventListener()
Return the database event listener, this allows database events to invalidate the cache.- Specified by:
getDatabaseEventListenerin interfaceDatabaseSession
-
setDatabaseEventListener
public void setDatabaseEventListener(DatabaseEventListener databaseEventListener)
PUBLIC: Set the database event listener, this allows database events to invalidate the cache.- Specified by:
setDatabaseEventListenerin interfaceDatabaseSession
-
setDatasourceAndInitialize
public void setDatasourceAndInitialize() throws DatabaseExceptionINTERNAL: Issue any pre connect and post connect without an actual connection to the database. Descriptors are initialized in postConnectDatasource and are used in DDL generation. This will look to set the schema platform via the JPA 2.1 properties or through a detection on the connection before DDL generation.- Throws:
DatabaseException
-
setOrDetectDatasource
protected void setOrDetectDatasource(boolean throwException)
INTERNAL: Will set the platform from specified schema generation properties or by detecting it through the connection (if one is available). Any connection that is open for detection is closed before this method returns.- Parameters:
throwException- - set to true if the caller cares to throw exceptions, false to swallow them.
-
getSequencingControl
public SequencingControl getSequencingControl()
PUBLIC: Return SequencingControl which used for sequencing setup and customization including management of sequencing preallocation.- Specified by:
getSequencingControlin interfaceDatabaseSession
-
getSequencing
public Sequencing getSequencing()
PUBLIC: Return the Sequencing object used by the session.- Overrides:
getSequencingin classAbstractSession
-
isSequencingCallbackRequired
public boolean isSequencingCallbackRequired()
INTERNAL: Indicates whether SequencingCallback is required. Always returns false if sequencing is not connected.
-
initializeSequencing
public void initializeSequencing()
INTERNAL: Creates sequencing object
-
addDescriptorsToSequencing
public void addDescriptorsToSequencing(java.util.Collection descriptors)
INTERNAL: If sequencing is connected then initializes sequences referenced by the passed descriptors, otherwise connects sequencing.
-
releaseJTSConnection
public void releaseJTSConnection()
INTERNAL: Called in the end of beforeCompletion of external transaction synchronization listener. Close the managed sql connection corresponding to the external transaction.- Overrides:
releaseJTSConnectionin classAbstractSession
-
addDescriptor
public void addDescriptor(ClassDescriptor descriptor)
PUBLIC: Add the descriptor to the session. All persistent classes must have a descriptor registered for them with the session. It is best to add the descriptors before login, if added after login the order in which descriptors are added is dependent on inheritance and references unless the addDescriptors method is used.- Specified by:
addDescriptorin interfaceDatabaseSession- See Also:
#addDescriptors(Vector),addDescriptors(org.eclipse.persistence.sessions.Project)
-
addDescriptors
public void addDescriptors(java.util.Collection descriptors)
PUBLIC: Add the descriptors to the session. All persistent classes must have a descriptor registered for them with the session. This method allows for a batch of descriptors to be added at once so that EclipseLink can resolve the dependencies between the descriptors and perform initialization optimally.- Specified by:
addDescriptorsin interfaceDatabaseSession- Parameters:
descriptors- The descriptors to be added to the session and project.
-
addDescriptors
public void addDescriptors(Project project)
PUBLIC: Add the descriptors to the session from the Project. This can be used to combine the descriptors from multiple projects into a single session. This can be called after the session has been connected as long as there are no external dependencies.- Specified by:
addDescriptorsin interfaceDatabaseSession
-
addSequence
public void addSequence(Sequence sequence)
PUBLIC: Add the sequence to the session. Allows to add a new sequence to the session even if the session is connected. If the session is connected then the sequence is added only if there is no sequence with the same name already in use. Call this method before addDescriptor(s) if need to add new descriptor with a new non-default sequence to connected session.- Specified by:
addSequencein interfaceDatabaseSession- See Also:
#addSequences(Collection)
-
connect
public void connect() throws DatabaseExceptionINTERNAL: Connect the session only.- Throws:
DatabaseException
-
disconnect
public void disconnect() throws DatabaseExceptionINTERNAL: Disconnect the accessor only.- Throws:
DatabaseException
-
getServerPlatform
public ServerPlatform getServerPlatform()
PUBLIC: Answer the server platform to handle server specific behavior for WLS, Oc4j, etc. If the user wants a different external transaction controller class or to provide some different behavior than the provided ServerPlatform(s), we recommend subclassing org.eclipse.persistence.platform.server.ServerPlatformBase (or a subclass), and overriding: ServerPlatformBase.getExternalTransactionControllerClass() ServerPlatformBase.registerMBean() ServerPlatformBase.unregisterMBean() for the desired behavior.- Specified by:
getServerPlatformin interfaceDatabaseSession- Specified by:
getServerPlatformin interfaceSession- Overrides:
getServerPlatformin classAbstractSession- See Also:
ServerPlatformBase
-
setServerPlatform
public 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. If the user wants a different external transaction controller class or to provide some different behavior than the provided ServerPlatform(s), we recommend subclassing org.eclipse.persistence.platform.server.ServerPlatformBase (or a subclass), and overriding: ServerPlatformBase.getExternalTransactionControllerClass() ServerPlatformBase.registerMBean() ServerPlatformBase.unregisterMBean() for the desired behavior.- Specified by:
setServerPlatformin interfaceDatabaseSession- See Also:
ServerPlatformBase
-
finalize
protected void finalize() throws DatabaseExceptionINTERNAL: Logout in case still connected.- Overrides:
finalizein classjava.lang.Object- Throws:
DatabaseException
-
getPlatform
public DatabasePlatform getPlatform()
INTERNAL: Return the database platform currently connected to. The platform is used for database specific behavior. NOTE: this must only be used for relational specific usage, it will fail for non-relational datasources.- Specified by:
getPlatformin interfaceSession- Overrides:
getPlatformin classAbstractSession
-
getDatasourcePlatform
public Platform getDatasourcePlatform()
INTERNAL: Return the database platform currently connected to. The platform is used for database specific behavior.- Specified by:
getDatasourcePlatformin interfaceCoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>- Specified by:
getDatasourcePlatformin interfaceSession- Overrides:
getDatasourcePlatformin classAbstractSession
-
getPlatform
public Platform getPlatform(java.lang.Class domainClass)
INTERNAL: Return the database platform currently connected to for specified class. The platform is used for database specific behavior.- Overrides:
getPlatformin classAbstractSession
-
initializeDescriptorIfSessionAlive
public void initializeDescriptorIfSessionAlive(ClassDescriptor descriptor)
INTERNAL: A descriptor may have been added after the session is logged in. In this case the descriptor must be allowed to initialize any dependencies on this session. Normally the descriptors are added before login, then initialized on login.
-
initializeDescriptors
public void initializeDescriptors()
INTERNAL: Allow each descriptor to initialize any dependencies on this session. This is done in two passes to allow the inheritance to be resolved first. Normally the descriptors are added before login, then initialized on login.
-
initializeDescriptors
public void initializeDescriptors(java.util.Map descriptors)
INTERNAL: Allow each descriptor to initialize any dependencies on this session. This is done in two passes to allow the inheritance to be resolved first. Normally the descriptors are added before login, then initialized on login. The descriptors session must be used, not the broker. Sequencing is (re)initialized: disconnected (if has been already connected), then connected.
-
initializeDescriptors
public void initializeDescriptors(java.util.Collection descriptors)
-
initializeDescriptors
public void initializeDescriptors(java.util.Map descriptors, boolean shouldInitializeSequencing)INTERNAL: Allow each descriptor to initialize any dependencies on this session. This is done in two passes to allow the inheritance to be resolved first. Normally the descriptors are added before login, then initialized on login. The descriptors session must be used, not the broker. If shouldInitializeSequencing parameter is true then sequencing is (re)initialized: disconnected (if has been connected), then connected. If shouldInitializeSequencing parameter is false then if sequencing has been already connected, then it stays connected: only the new sequences used by the passed descriptors are initialized; otherwise, if sequencing has NOT been connected then it is connected (just like in shouldInitializeSequencing==true case); disconnected (if has been connected), then connected.
-
initializeDescriptors
public void initializeDescriptors(java.util.Collection descriptors, boolean shouldInitializeSequencing)
-
isDatabaseSession
public boolean isDatabaseSession()
INTERNAL: Return if this session is a database session.- Specified by:
isDatabaseSessionin interfaceSession- Overrides:
isDatabaseSessionin classAbstractSession
-
isProtectedSession
public boolean isProtectedSession()
PUBLIC: Returns true if Protected Entities should be built within this session- Overrides:
isProtectedSessionin classAbstractSession
-
getReadLogin
protected Login getReadLogin()
INTERNAL: Return the login for the read connection. Used by the platform autodetect feature
-
loginAndDetectDatasource
public void loginAndDetectDatasource() throws DatabaseExceptionPUBLIC: Connect to the database using the predefined login. During connection, attempt to auto detect the required database platform. This method can be used in systems where for ease of use developers have EclipseLink autodetect the platform. To be safe, however, the platform should be configured directly. The login must have been assigned when or after creating the session.- Throws:
DatabaseException
-
login
public void login() throws DatabaseExceptionPUBLIC: Connect to the database using the predefined login. The login must have been assigned when or after creating the session.- Specified by:
loginin interfaceDatabaseSession- Throws:
DatabaseException- See Also:
login(Login)
-
preConnectDatasource
protected void preConnectDatasource()
INTERNAL: This method includes all of the code that is issued before the datasource is connected to.
-
postConnectDatasource
protected void postConnectDatasource()
INTERNAL: This method includes all of the code that is issued after the datasource is connected to.
-
postLogin
public void postLogin()
INTERNAL: Rise postLogin event.
-
login
public void login(java.lang.String userName, java.lang.String password) throws DatabaseExceptionPUBLIC: Connect to the database using the given user name and password. The additional login information must have been preset in the session's login attribute. This is the login that should be used if each user has their own id, but all users share the same database configuration.- Specified by:
loginin interfaceDatabaseSession- Throws:
DatabaseException
-
login
public void login(Login login) throws DatabaseException
PUBLIC: Connect to the database using the given login. The login may also the preset and the login() protocol called. This is the login should only be used if each user has their own database configuration.- Specified by:
loginin interfaceDatabaseSession- Throws:
DatabaseException
-
logout
public void logout() throws DatabaseExceptionPUBLIC: Disconnect from the database.- Specified by:
logoutin interfaceDatabaseSession- Throws:
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.
-
initializeConnectedTime
public void initializeConnectedTime()
PUBLIC: Initialize the time that this session got connected. This can help determine how long a session has been connected.
-
getConnectedTime
public long getConnectedTime()
PUBLIC: Answer the time that this session got connected. This can help determine how long a session has been connected.
-
writeAllObjects
public void writeAllObjects(java.util.Collection domainObjects) throws DatabaseException, OptimisticLockExceptionPUBLIC: Write all of the objects and all of their privately owned parts in the database. The objects will be committed through a single transaction.- Specified by:
writeAllObjectsin interfaceDatabaseSession- Throws:
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.
-
writeAllObjects
public void writeAllObjects(java.util.Vector domainObjects) throws DatabaseException, OptimisticLockExceptionPUBLIC: Write all of the objects and all of their privately owned parts in the database. The objects will be committed through a single transaction.- Throws:
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.
-
retryQuery
public java.lang.Object retryQuery(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession)
INTERNAL: A query execution failed due to an invalid query. Re-connect and retry the query.- Overrides:
retryQueryin classAbstractSession
-
getTuner
public SessionTuner getTuner()
Return the tuner used to tune the configuration of this session.
-
setTuner
public void setTuner(SessionTuner tuner)
Set the tuner used to tune the configuration of this session.
-
-