Class AbstractSession

    • Field Detail

      • exceptionHandler

        protected transient ExceptionHandler exceptionHandler
        ExceptionHandler handles database exceptions.
      • integrityChecker

        protected transient IntegrityChecker integrityChecker
        IntegrityChecker catch all the descriptor Exceptions.
      • project

        protected transient Project project
        The project stores configuration information, such as the descriptors and login.
      • transactionMutex

        protected transient ConcurrencyManager transactionMutex
        Ensure mutual exclusion of the session's transaction state across multiple threads.
      • identityMapAccessor

        protected IdentityMapAccessor identityMapAccessor
        Manages the live object cache.
      • wasJTSTransactionInternallyStarted

        protected boolean wasJTSTransactionInternallyStarted
        If Transactions were externally started
      • accessors

        protected transient Collection<Accessor> accessors
        The connection to the data store.
      • platform

        protected transient Platform platform
        Allow the datasource platform to be cached.
      • attributeGroups

        protected Map<String,​AttributeGroup> attributeGroups
        Stores predefined reusable AttributeGroups.
      • jpaQueriesProcessed

        protected boolean jpaQueriesProcessed
        Stores predefined not yet parsed JPQL queries.
      • commitManager

        protected transient CommitManager commitManager
        Resolves referential integrity on commits.
      • profiler

        protected transient SessionProfiler profiler
        Tool that log performance information.
      • broker

        protected transient AbstractSession broker
        Support being owned by a session broker.
      • name

        protected String name
        Used to identify a session when using the session broker.
      • numberOfActiveUnitsOfWork

        protected transient int numberOfActiveUnitsOfWork
        Keep track of active units of work.
      • objectsLockedForClone

        protected Map objectsLockedForClone
        This collection will be used to store those objects that are currently locked for the clone process. It should be populated with an EclipseLinkIdentityHashMap
      • sessionLog

        protected transient SessionLog sessionLog
        Destination for logged messages and SQL.
      • logSessionString

        protected transient String logSessionString
        When logging the name of the session is typed: class name + system hashcode.
      • eventManager

        protected transient SessionEventManager eventManager
        Stores the event listeners for this session.
      • properties

        protected Map<String,​Object> properties
        Allow for user defined properties.
      • externalTransactionController

        protected transient ExternalTransactionController externalTransactionController
        Delegate that handles synchronizing a UnitOfWork with an external transaction.
      • lastDescriptorAccessed

        protected transient ClassDescriptor lastDescriptorAccessed
        Last descriptor accessed, use to optimize descriptor lookup.
      • tablePerTenantDescriptors

        protected transient List<ClassDescriptor> tablePerTenantDescriptors
        PERF: cache table per tenant descriptors needing to be initialized per EM
      • tablePerTenantQueries

        protected transient List<DatabaseQuery> tablePerTenantQueries
        PERF: cache table per tenant queries needing to be initialized per EM
      • isInBroker

        protected boolean isInBroker
        Used to determine If a session is in a Broker or not
      • commandManager

        protected transient CommandManager commandManager
        Used to connect this session to EclipseLink cluster for distributed command
      • shouldCheckWriteLock

        protected boolean shouldCheckWriteLock
        PERF: Cache the write-lock check to avoid cost of checking in every register/clone.
      • shouldPropagateChanges

        protected boolean shouldPropagateChanges
        Determined whether changes should be propagated to an EclipseLink cluster
      • isInProfile

        protected boolean isInProfile
        Used to determine If a session is in a profile or not
      • isLoggingOff

        protected boolean isLoggingOff
        PERF: Quick check if logging is OFF entirely.
      • isFinalizersEnabled

        protected boolean isFinalizersEnabled
        PERF: Allow for finalizers to be enabled, currently enables client-session finalize.
      • activeCommandThreads

        protected transient ExposedNodeLinkedList activeCommandThreads
        List of active command threads.
      • isSynchronized

        protected boolean isSynchronized
        Indicates whether the session is synchronized. In case external transaction controller is used isSynchronized==true means the session's jta connection will be freed during external transaction callback.
      • defaultReferenceMode

        protected ReferenceMode defaultReferenceMode
        Stores the default reference mode that a UnitOfWork will use when referencing managed objects.
        See Also:
        ReferenceMode
      • pessimisticLockTimeoutDefault

        protected Integer pessimisticLockTimeoutDefault
        Default pessimistic lock timeout value.
      • pessimisticLockTimeoutUnitDefault

        protected TimeUnit pessimisticLockTimeoutUnitDefault
      • queryTimeoutDefault

        protected int queryTimeoutDefault
      • queryTimeoutUnitDefault

        protected TimeUnit queryTimeoutUnitDefault
      • isConcurrent

        protected boolean isConcurrent
        Allow a session to enable concurrent processing.
      • staticMetamodelClasses

        protected Map<String,​String> staticMetamodelClasses
        This map will hold onto class to static metamodel class references from JPA.
      • deferredEvents

        protected List<DescriptorEvent> deferredEvents
        temporarily holds a list of events that must be fired after the current operation completes. Initialy created for postClone events.
      • isExecutingEvents

        protected boolean isExecutingEvents
        records that the UOW is executing deferred events. Events could cause operations to occur that may attempt to restart the event execution. This must be avoided
      • partitioningPolicy

        protected PartitioningPolicy partitioningPolicy
        Allow queries to be targeted at specific connection pools.
      • metadatalistener

        protected MetadataRefreshListener metadatalistener
        the MetadataRefreshListener is used with RCM to force a refresh of the metadata used within EntityManagerFactoryWrappers
      • multitenantContextProperties

        protected Set<String> multitenantContextProperties
        Stores the set of multitenant context properties this session requires
      • queryBuilder

        protected transient JPAQueryBuilder queryBuilder
        Store the query builder used to parse JPQL.
      • serializer

        protected transient Serializer serializer
        Set the Serializer to use by default for serialization.
      • injectionManager

        protected transient InjectionManager injectionManager
        Allow CDI injection of entity listeners
      • shouldOptimizeResultSetAccess

        protected boolean shouldOptimizeResultSetAccess
        Indicates whether ObjectLevelReadQuery should by default use ResultSet Access optimization. Optimization specified by the session is ignored if incompatible with other query settings.
      • tolerateInvalidJPQL

        protected boolean tolerateInvalidJPQL
        Indicates whether Session creation should tolerate an invalid NamedQuery. If true, an exception will be thrown on .createNamedQuery(..) rather than at init time.
    • Constructor Detail

      • AbstractSession

        protected AbstractSession()
        INTERNAL: Create and return a new session. This should only be called if the database login information is not know at the time of creation. Normally it is better to call the constructor that takes the login information as an argument so that the session can initialize itself to the platform information given in the login.
      • AbstractSession

        protected AbstractSession​(int nothing)
        INTERNAL: Create a blank session, used for proxy session.
      • AbstractSession

        public AbstractSession​(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.
      • AbstractSession

        public AbstractSession​(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

      • getSerializer

        public Serializer getSerializer()
        Return the Serializer to use by default for serialization.
        Specified by:
        getSerializer in interface Session
      • setSerializer

        public void setSerializer​(Serializer serializer)
        Set the Serializer to use by default for serialization.
        Specified by:
        setSerializer in interface Session
      • getQueryBuilder

        public JPAQueryBuilder getQueryBuilder()
        INTERNAL Return the query builder used to parser JPQL.
      • setQueryBuilder

        public void setQueryBuilder​(JPAQueryBuilder queryBuilder)
        INTERNAL Set the query builder used to parser JPQL.
      • buildDefaultQueryBuilder

        protected JPAQueryBuilder buildDefaultQueryBuilder()
        INTERNAL Build the JPQL builder based on session properties.
      • setLoggingOff

        public void setLoggingOff​(boolean loggingOff)
        INTERNAL: PERF: Used for quick turning logging ON/OFF entirely.
        Parameters:
        loggingOff - Logging is turned off when true and turned on when false.
      • isLoggingOff

        public boolean isLoggingOff()
        INTERNAL: PERF: Used for quick check if logging is OFF entirely.
      • getNextQueryId

        public long getNextQueryId()
        INTERNAL: Called by a sessions queries to obtain individual query ids. CR #2698903
      • acquireNonSynchronizedUnitOfWork

        public UnitOfWorkImpl acquireNonSynchronizedUnitOfWork()
        INTERNAL: Return a unit of work for this session not registered with the JTS transaction.
      • acquireNonSynchronizedUnitOfWork

        public UnitOfWorkImpl acquireNonSynchronizedUnitOfWork​(ReferenceMode referenceMode)
        INTERNAL: Return a unit of work for this session not registered with the JTS transaction.
      • acquireUnitOfWork

        public UnitOfWorkImpl acquireUnitOfWork()
        PUBLIC: Return a unit of work for this session. The unit of work is an object level transaction that allows a group of changes to be applied as a unit.
        Specified by:
        acquireUnitOfWork in interface Session
        See Also:
        UnitOfWorkImpl
      • acquireUnitOfWork

        public UnitOfWorkImpl acquireUnitOfWork​(ReferenceMode referenceMode)
        PUBLIC: Return a unit of work for this session. The unit of work is an object level transaction that allows a group of changes to be applied as a unit.
        Specified by:
        acquireUnitOfWork in interface Session
        Parameters:
        referenceMode - The reference type the UOW should use internally when referencing Working clones. Setting this to WEAK means the UOW will use weak references to reference clones that support active object change tracking and hard references for deferred change tracked objects. Setting to FORCE_WEAK means that all objects will be referenced by weak references and if the application no longer references the clone the clone may be garbage collected. If the clone has uncommitted changes then those changes will be lost.
        See Also:
        UnitOfWorkImpl
      • addAlias

        public void addAlias​(String alias,
                             ClassDescriptor descriptor)
        PUBLIC: Add an alias for the descriptor
      • addJPAQuery

        public void addJPAQuery​(DatabaseQuery query)
        INTERNAL: Return all pre-defined not yet parsed EJBQL queries.
        Specified by:
        addJPAQuery in interface Session
      • addJPATablePerTenantQuery

        public void addJPATablePerTenantQuery​(DatabaseQuery query)
        INTERNAL: Return all pre-defined not yet parsed EJBQL multitenant queries.
      • addMultitenantContextProperty

        public void addMultitenantContextProperty​(String contextProperty)
        PUBLIC: Return a set of multitenant context properties this session
      • addQuery

        protected void addQuery​(DatabaseQuery query,
                                boolean nameMustBeUnique)
        INTERNAL: Add the query to the session queries.
      • addQuery

        public void addQuery​(String name,
                             DatabaseQuery query)
        PUBLIC: Add the query to the session queries with the given name. This allows for common queries to be pre-defined, reused and executed by name.
        Specified by:
        addQuery in interface Session
      • addQuery

        public void addQuery​(String name,
                             DatabaseQuery query,
                             boolean replace)
        PUBLIC: Add the query to the session queries with the given name. This allows for common queries to be pre-defined, reused and executed by name.
      • addStaticMetamodelClass

        public void addStaticMetamodelClass​(String modelClassName,
                                            String metamodelClassName)
        INTERNAL: Add a metamodel class to model class reference.
      • addTablePerTenantDescriptor

        protected void addTablePerTenantDescriptor​(ClassDescriptor descriptor)
        INTERNAL: Add a descriptor that is uses a table per tenant multitenant policy.
      • addTablePerTenantQuery

        protected void addTablePerTenantQuery​(DatabaseQuery query)
        INTERNAL: Add a query that queries a table per tenant entity
      • basicBeginTransaction

        protected void basicBeginTransaction()
                                      throws DatabaseException
        INTERNAL: Called by beginTransaction() to start a transaction. This starts a real database transaction. Allows retry if the connection is dead.
        Throws:
        DatabaseException
      • basicBeginTransaction

        protected void basicBeginTransaction​(Accessor accessor)
                                      throws DatabaseException
        INTERNAL: Called by beginTransaction() to start a transaction. This starts a real database transaction. Allows retry if the connection is dead.
        Throws:
        DatabaseException
      • 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, if applicable releases accessor.
      • basicCommitTransaction

        protected void basicCommitTransaction()
                                       throws DatabaseException
        INTERNAL: Called by commitTransaction() to commit a transaction. This commits the active transaction.
        Throws:
        DatabaseException
      • basicRollbackTransaction

        protected void basicRollbackTransaction()
                                         throws DatabaseException
        INTERNAL: Called by rollbackTransaction() to rollback a transaction. This rolls back the active transaction.
        Throws:
        DatabaseException
      • beginExternalTransaction

        public boolean beginExternalTransaction()
        INTERNAL: Attempts to begin an external transaction. Returns true only in one case - external transaction has been internally started during this method call: wasJTSTransactionInternallyStarted()==false in the beginning of this method and wasJTSTransactionInternallyStarted()==true in the end of this method.
      • beginTransaction

        public void beginTransaction()
                              throws DatabaseException,
                                     ConcurrencyException
        PUBLIC: Begin a transaction on the database. This allows a group of database modification to be committed or rolled back as a unit. All writes/deletes will be sent to the database be will not be visible to other users until commit. Although databases do not allow nested transaction, EclipseLink supports nesting through only committing to the database on the outer commit.
        Throws:
        DatabaseException - if the database connection is lost or the begin is rejected.
        ConcurrencyException - if this session's transaction is acquired by another thread and a timeout occurs.
        See Also:
        isInTransaction()
      • checkHierarchyForDescriptor

        protected ClassDescriptor checkHierarchyForDescriptor​(Class theClass)
        Check to see if the descriptor of a superclass can be used to describe this class
        Parameters:
        theClass -
        Returns:
        ClassDescriptor
      • cleanUpInjectionManager

        public void cleanUpInjectionManager()
        allow the entity listener injection manager to clean itself up.
      • clearIntegrityChecker

        public void clearIntegrityChecker()
        PUBLIC: clear the integrityChecker. IntegrityChecker holds all the ClassDescriptor Exceptions.
        Specified by:
        clearIntegrityChecker in interface Session
      • clearLastDescriptorAccessed

        public void clearLastDescriptorAccessed()
        INTERNAL: Clear the the lastDescriptorAccessed cache.
      • clearDescriptors

        public void clearDescriptors()
        INTERNAL: Clear the the descriptors cache.
      • clearProfile

        public void clearProfile()
        PUBLIC: Clear the profiler, this will end the current profile operation.
        Specified by:
        clearProfile in interface Session
      • clone

        public Object clone()
        INTERNAL: Clones the descriptor
        Overrides:
        clone in class Object
      • commitExternalTransaction

        public boolean commitExternalTransaction()
        INTERNAL: Attempts to commit the running internally started external transaction. Returns true only in one case - external transaction has been internally committed during this method call: wasJTSTransactionInternallyStarted()==true in the beginning of this method and wasJTSTransactionInternallyStarted()==false in the end of this method.
      • commitTransaction

        public void commitTransaction()
                               throws DatabaseException,
                                      ConcurrencyException
        PUBLIC: Commit the active database transaction. This allows a group of database modification to be committed or rolled back as a unit. All writes/deletes will be sent to the database be will not be visible to other users until commit. Although databases do not allow nested transaction, EclipseLink supports nesting through only committing to the database on the outer commit.
        Throws:
        DatabaseException - most databases validate changes as they are done, normally errors do not occur on commit unless the disk fails or the connection is lost.
        ConcurrencyException - if this session is not within a transaction.
      • compareObjects

        public boolean compareObjects​(Object firstObject,
                                      Object secondObject)
        INTERNAL: Return if the two object match completely. This checks the objects attributes and their private parts.
      • compareObjectsDontMatch

        public boolean compareObjectsDontMatch​(Object firstObject,
                                               Object secondObject)
        TESTING: Return true if the object do not match. This checks the objects attributes and their private parts.
      • containsQuery

        public boolean containsQuery​(String queryName)
        PUBLIC: Return true if the pre-defined query is defined on the session.
        Specified by:
        containsQuery in interface Session
      • copy

        public Object copy​(Object originalObjectOrObjects)
        PUBLIC: Return a complete copy of the object or of collection of objects. In case of collection all members should be either entities of the same type or have a common inheritance hierarchy mapped root class. This can be used to obtain a scratch copy of an object, or for templatizing an existing object into another new object. The object and all of its privately owned parts will be copied.
        Specified by:
        copy in interface Session
        See Also:
        copy(Object, AttributeGroup)
      • copy

        public Object copy​(Object originalObjectOrObjects,
                           AttributeGroup group)
        PUBLIC: Return a complete copy of the object or of collection of objects. In case of collection all members should be either entities of the same type or have a common inheritance hierarchy mapped root class. This can be used to obtain a scratch copy of an object, or for templatizing an existing object into another new object. If there are no attributes in the group then the object and all of its privately owned parts will be copied. Otherwise only the attributes included into the group will be copied.
        Specified by:
        copy in interface Session
      • copyReadOnlyClasses

        public Vector copyReadOnlyClasses()
        INTERNAL: Copy the read only classes from the unit of work Added Nov 8, 2000 JED for Patch 2.5.1.8 Ref: Prs 24502
      • createProtectedInstanceFromCachedData

        public Object createProtectedInstanceFromCachedData​(Object cached,
                                                            Integer refreshCascade,
                                                            ClassDescriptor descriptor)
        INTERNAL: This method is similar to getAndCloneCacheKeyFromParent. It purpose is to get protected cache data from the shared cache and build/return a protected instance.
      • checkAndRefreshInvalidObject

        public void checkAndRefreshInvalidObject​(Object object,
                                                 CacheKey cacheKey,
                                                 ClassDescriptor descriptor)
        INTERNAL: Check if the object is invalid and refresh it. This is used to ensure that no invalid objects are registered.
      • isConsideredInvalid

        public boolean isConsideredInvalid​(Object object,
                                           CacheKey cacheKey,
                                           ClassDescriptor descriptor)
        INTERNAL: Check if the object is invalid and *should* be refreshed. This is used to ensure that no invalid objects are cloned.
      • deferEvent

        public void deferEvent​(DescriptorEvent event)
        INTERNAL: Add an event to the deferred list. Events will be fired after the operation completes
      • deleteAllObjects

        public void deleteAllObjects​(Collection domainObjects)
                              throws DatabaseException,
                                     OptimisticLockException
        PUBLIC: delete all of the objects and all of their privately owned parts in the database. The allows for a group of objects to be deleted as a unit. The objects will be deleted through a single transactions.
        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.
      • deleteObject

        public Object deleteObject​(Object domainObject)
                            throws DatabaseException,
                                   OptimisticLockException
        PUBLIC: Delete the object and all of its privately owned parts from the database. The delete operation can be customized through using a delete query.
        Throws:
        DatabaseException - if an error occurs on the database, these include constraint violations, security violations and general database errors. An database error is not raised if the object is already deleted or no rows are effected.
        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.
        See Also:
        DeleteObjectQuery
      • dontLogMessages

        public void dontLogMessages()
        PUBLIC: Turn off logging
        Specified by:
        dontLogMessages in interface Session
      • endOperationProfile

        public void endOperationProfile​(String operationName,
                                        DatabaseQuery query,
                                        int weight)
        INTERNAL: End the operation timing.
      • updateTablePerTenantDescriptors

        public void updateTablePerTenantDescriptors​(String property,
                                                    Object value)
        INTERNAL: Set the table per tenant. This should be called per client session after the start of a transaction. From JPA this method is called on the entity manager by setting the multitenant table per tenant property.
      • incrementProfile

        public void incrementProfile​(String operationName)
        INTERNAL: Updates the count of SessionProfiler event
        Specified by:
        incrementProfile in interface CommandProcessor
      • incrementProfile

        public void incrementProfile​(String operationName,
                                     DatabaseQuery query)
        INTERNAL: Updates the count of SessionProfiler event
      • executeDeferredEvents

        public void executeDeferredEvents()
        INTERNAL: Causes any deferred events to be fired. Called after operation completes
      • releaseConnectionAfterCall

        public void releaseConnectionAfterCall​(DatabaseQuery query)
        INTERNAL: Release (if required) connection after call.
        Parameters:
        query -
      • executeSelectingCall

        public Vector executeSelectingCall​(Call call)
                                    throws DatabaseException
        PUBLIC: Execute the call on the database and return the result. The call must return a value, if no value is return executeNonSelectCall must be used. The call can be a stored procedure call, SQL call or other type of call. A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data.

        Example:

        session.executeSelectingCall(new SQLCall("Select * from Employee");

        Specified by:
        executeSelectingCall in interface Session
        Throws:
        DatabaseException
        See Also:
        executeNonSelectingCall(Call)
      • executeSQL

        public Vector executeSQL​(String sqlString)
                          throws DatabaseException
        PUBLIC: Execute the sql on the database and return the result. It must return a value, if no value is return executeNonSelectingSQL must be used. A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.

        Example:

        session.executeSelectingCall("Select * from Employee");

        Specified by:
        executeSQL in interface Session
        Throws:
        DatabaseException
        See Also:
        executeSelectingCall(Call)
      • getAccessor

        public Accessor getAccessor()
        INTERNAL: This should normally not be used, most sessions do not have a single accessor. ServerSession has a set of connection pools. ClientSession only has an accessor during a transaction. SessionBroker has multiple accessors. getAccessors() should be used to support partitioning. To maintain backward compatibility, and to support certain cases that required a default accessor, this returns the first accessor.
      • getAccessors

        public Collection<Accessor> getAccessors()
        INTERNAL: This should normally not be used, most sessions do not have specific accessors. ServerSession has a set of connection pools. ClientSession only has an accessor during a transaction. SessionBroker has multiple accessors. getAccessors() is used to support partitioning. If the accessor is null, this lazy initializes one for backwardcompatibility with DatabaseSession.
      • getActiveSession

        public Session getActiveSession()
        PUBLIC: Return the active session for the current active external (JTS) transaction. This should only be used with JTS and will return the session if no external transaction exists.
        Specified by:
        getActiveSession in interface Session
      • getActiveUnitOfWork

        public UnitOfWork getActiveUnitOfWork()
        PUBLIC: Return the active unit of work for the current active external (JTS) transaction. This should only be used with JTS and will return null if no external transaction exists.
        Specified by:
        getActiveUnitOfWork in interface Session
      • getAliasDescriptors

        public Map getAliasDescriptors()
        INTERNAL: Returns the alias descriptors Map.
      • getBroker

        public AbstractSession getBroker()
        INTERNAL: Allow the session to be used from a session broker.
      • getRootSession

        public AbstractSession getRootSession​(DatabaseQuery query)
        INTERNAL: The session that this query is executed against when not in transaction. The session containing the shared identity map.

        In most cases this is the root ServerSession or DatabaseSession.

        In cases where objects are not to be cached in the global identity map an alternate session may be returned:

        • A ClientSession if in transaction
        • An isolated ClientSession or HistoricalSession
        • A registered session of a root SessionBroker
      • getParent

        public AbstractSession getParent()
        INTERNAL: Gets the parent session.
      • getParentIdentityMapSession

        public AbstractSession getParentIdentityMapSession​(DatabaseQuery query)
        INTERNAL: Gets the next link in the chain of sessions followed by a query's check early return, the chain of sessions with identity maps all the way up to the root session.
      • getParentIdentityMapSession

        public AbstractSession getParentIdentityMapSession​(DatabaseQuery query,
                                                           boolean canReturnSelf,
                                                           boolean terminalOnly)
        INTERNAL: Gets the next link in the chain of sessions followed by a query's check early return, the chain of sessions with identity maps all the way up to the root session.

        Used for session broker which delegates to registered sessions, or UnitOfWork which checks parent identity map also.

        Parameters:
        canReturnSelf - true when method calls itself. If the path starting at this is acceptable. Sometimes true if want to move to the first valid session, i.e. executing on ClientSession when really should be on ServerSession.
        terminalOnly - return the session we will execute the call on, not the next step towards it.
        Returns:
        this if there is no next link in the chain
      • getParentIdentityMapSession

        public AbstractSession getParentIdentityMapSession​(ClassDescriptor descriptor,
                                                           boolean canReturnSelf,
                                                           boolean terminalOnly)
        INTERNAL: Returns the appropriate IdentityMap session for this descriptor. Sessions can be chained and each session can have its own Cache/IdentityMap. Entities can be stored at different levels based on Cache Isolation. This method will return the correct Session for a particular Entity class based on the Isolation Level and the attributes provided.

        Parameters:
        canReturnSelf - true when method calls itself. If the path starting at this is acceptable. Sometimes true if want to move to the first valid session, i.e. executing on ClientSession when really should be on ServerSession.
        terminalOnly - return the last session in the chain where the Enitity is stored.
        Returns:
        Session with the required IdentityMap
      • getPessimisticLockTimeoutDefault

        public Integer getPessimisticLockTimeoutDefault()
        INTERNAL: Returns the default pessimistic lock timeout value.
      • getPessimisticLockTimeoutUnitDefault

        public TimeUnit getPessimisticLockTimeoutUnitDefault()
      • getQueryTimeoutDefault

        public int getQueryTimeoutDefault()
        PUBLIC: Return the default query timeout for this session. This timeout will apply to any queries that do not have a timeout set, and that do not have a default timeout defined in their descriptor.
      • getQueryTimeoutUnitDefault

        public TimeUnit getQueryTimeoutUnitDefault()
      • getExecutionSession

        public AbstractSession getExecutionSession​(DatabaseQuery query)
        INTERNAL: Gets the session which this query will be executed on. Generally will be called immediately before the call is translated, which is immediately before session.executeCall.

        Since the execution session also knows the correct datasource platform to execute on, it is often used in the mappings where the platform is needed for type conversion, or where calls are translated.

        Is also the session with the accessor. Will return a ClientSession if it is in transaction and has a write connection.

        Parameters:
        query - may store session name or reference class for brokers case
        Returns:
        a session with a live accessor
      • hasCommitManager

        public boolean hasCommitManager()
        INTERNAL: Return if the commit manager has been set.
      • getCommitManager

        public CommitManager getCommitManager()
        INTERNAL: The commit manager is used to resolve referential integrity on commits of multiple objects. All brokered sessions share the same commit manager.
      • getClassDescriptor

        public ClassDescriptor getClassDescriptor​(Class theClass)
        ADVANCED: Return the descriptor specified for the class. If the class does not have a descriptor but implements an interface that is also implemented by one of the classes stored in the map, that descriptor will be stored under the new class. If a descriptor does not exist for the Class parameter, null is returned. If the passed Class parameter is null, then null will be returned.
        Specified by:
        getClassDescriptor in interface Session
      • getClassDescriptor

        public ClassDescriptor getClassDescriptor​(Object domainObject)
        ADVANCED: Return the descriptor specified for the object's class. If a descriptor does not exist for the Object parameter, null is returned. If the passed Object parameter is null, then null will be returned.
        Specified by:
        getClassDescriptor in interface Session
      • getDescriptorForAlias

        public ClassDescriptor getDescriptorForAlias​(String alias)
        PUBLIC: Return the descriptor for the alias.
        Specified by:
        getDescriptorForAlias in interface Session
        Parameters:
        alias - The descriptor alias.
        Returns:
        The descriptor for the alias or null if no descriptor was found.
      • hasEventManager

        public boolean hasEventManager()
        INTERNAL: Return if an event manager has been set.
      • getExceptionHandlerClass

        public String getExceptionHandlerClass()
        INTERNAL: Return a string which represents my ExceptionHandler's class Added for F2104: Properties.xml - gn
      • getExceptionHandler

        public ExceptionHandler getExceptionHandler()
        PUBLIC: Return the ExceptionHandler.Exception handler can catch errors that occur on queries or during database access.
        Specified by:
        getExceptionHandler in interface Session
      • getExternalTransactionController

        public ExternalTransactionController getExternalTransactionController()
        PUBLIC: Used for JTS integration. If your application requires to have JTS control transactions instead of EclipseLink an external transaction controller must be specified. EclipseLink provides JTS controllers for several JTS implementations including JTS 1.0, Weblogic 5.1 and WebSphere 3.0.
        Specified by:
        getExternalTransactionController in interface Session
        See Also:
        JTATransactionController
      • getIdentityMapAccessor

        public IdentityMapAccessor getIdentityMapAccessor()
        PUBLIC: The IdentityMapAccessor is the preferred way of accessing IdentityMap funcitons This will return an object which implements an interface which exposes all public IdentityMap functions.
        Specified by:
        getIdentityMapAccessor in interface Session
      • getIdentityMapAccessorInstance

        public IdentityMapAccessor getIdentityMapAccessorInstance()
        INTERNAL: Return the internally available IdentityMapAccessor instance.
      • getIntegrityChecker

        public IntegrityChecker getIntegrityChecker()
        PUBLIC: Returns the integrityChecker.IntegrityChecker holds all the ClassDescriptor Exceptions.
        Specified by:
        getIntegrityChecker in interface Session
      • getJPATablePerTenantQueries

        public List<DatabaseQuery> getJPATablePerTenantQueries()
        ADVANCED: Return all pre-defined not yet parsed JPQL queries.
      • getLog

        public Writer getLog()
        PUBLIC: Return the writer to which an accessor writes logged messages and SQL. If not set, this reference defaults to a writer on System.out. To enable logging, logMessages must be turned on.
        Specified by:
        getLog in interface Session
        See Also:
        setLoggingOff(boolean)
      • getLogSessionString

        public String getLogSessionString()
        INTERNAL: Return the name of the session: class name + system hashcode.

        This should be the implementation of toString(), and also the value should be calculated in the constructor for it is used all the time. However everything is lazily initialized now and the value is transient for the system hashcode could vary?

      • getSessionTypeString

        public String getSessionTypeString()
        INTERNAL: Returns the type of session, its class.

        Override to hide from the user when they are using an internal subclass of a known class.

        A user does not need to know that their UnitOfWork is a non-deferred UnitOfWork, or that their ClientSession is an IsolatedClientSession.

      • getStaticMetamodelClass

        public String getStaticMetamodelClass​(String modelClassName)
        INTERNAL: Return the static metamodel class associated with the given model class if available. Callers must handle null.
      • getLogin

        public DatabaseLogin getLogin()
        OBSOLETE: Return the login, the login holds any database connection information given. This has been replaced by getDatasourceLogin to make use of the Login interface to support non-relational datasources, if DatabaseLogin API is required it will need to be cast.
        Specified by:
        getLogin in interface Session
      • getMappedSuperclass

        public ClassDescriptor getMappedSuperclass​(String className)
        INTERNAL: Return the mapped superclass descriptor if one exists for the given class name. Must check any broker as well.
      • getMultitenantContextProperties

        public Set<String> getMultitenantContextProperties()
        PUBLIC: Return a set of multitenant context properties this session
      • getName

        public String getName()
        PUBLIC: Return the name of the session. This is used with the session broker, or to give the session a more meaningful name.
        Specified by:
        getName in interface Session
      • getNumberOfActiveUnitsOfWork

        public int getNumberOfActiveUnitsOfWork()
        INTERNAL: Return the number of units of work connected.
      • getCacheKeyFromTargetSessionForMerge

        protected CacheKey getCacheKeyFromTargetSessionForMerge​(Object implementation,
                                                                ObjectBuilder builder,
                                                                ClassDescriptor descriptor,
                                                                MergeManager mergeManager)
        INTERNAL: For use within the merge process this method will get an object from the shared cache using a readlock. If a readlock is unavailable then the merge manager will be transitioned to deferred locks and a deferred lock will be used.
      • 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:
        getPlatform in interface Session
      • getLoader

        public ClassLoader getLoader()
        INTERNAL: Return the class loader for the session's application. This loader should be able to load any application or EclipseLink class.
      • getServerPlatform

        public ServerPlatform getServerPlatform()
        INTERNAL: Marked internal as this is not customer API but helper methods for accessing the server platform from within EclipseLink's other sessions types (ie not DatabaseSession)
        Specified by:
        getServerPlatform in interface Session
      • getProfiler

        public SessionProfiler getProfiler()
        PUBLIC: Return the profiler. The profiler is a tool that can be used to determine performance bottlenecks. The profiler can be queries to print summaries and configure for logging purposes.
        Specified by:
        getProfiler in interface Session
      • hasProperties

        public boolean hasProperties()
        INTERNAL: Allow to check for user defined properties.
      • hasTablePerTenantDescriptors

        public boolean hasTablePerTenantDescriptors()
        INTERNAL: Return list of table per tenant multitenant descriptors.
      • hasTablePerTenantQueries

        public boolean hasTablePerTenantQueries()
        INTERNAL: Return a list of table per tenant multitenant queries.
      • getProperty

        public Object getProperty​(String name)
        ADVANCED: Returns the user defined property.
        Specified by:
        getProperty in interface Session
      • getAttributeGroups

        public Map<String,​AttributeGroup> getAttributeGroups()
        ADVANCED Return all predefined attribute groups
      • getAllQueries

        public List<DatabaseQuery> getAllQueries()
        INTERNAL: Return the pre-defined queries in this session. A single vector containing all the queries is returned.
        See Also:
        getQueries()
      • getQuery

        public DatabaseQuery getQuery​(String name)
        PUBLIC: Return the query from the session pre-defined queries with the given name. This allows for common queries to be pre-defined, reused and executed by name.
        Specified by:
        getQuery in interface Session
      • getQuery

        public DatabaseQuery getQuery​(String name,
                                      List arguments)
        PUBLIC: Return the query from the session pre-defined queries with the given name and argument types. This allows for common queries to be pre-defined, reused and executed by name. This method should be used if the Session has multiple queries with the same name but different arguments.
        Specified by:
        getQuery in interface Session
        See Also:
        getQuery(String)
      • getQuery

        public DatabaseQuery getQuery​(String name,
                                      Vector arguments)
        PUBLIC: Return the query from the session pre-defined queries with the given name and argument types. This allows for common queries to be pre-defined, reused and executed by name. This method should be used if the Session has multiple queries with the same name but different arguments.
        See Also:
        getQuery(String)
      • getQuery

        public DatabaseQuery getQuery​(String name,
                                      Vector arguments,
                                      boolean shouldSearchParent)
        INTERNAL: Return the query from the session pre-defined queries with the given name and argument types. This allows for common queries to be pre-defined, reused and executed by name. This method should be used if the Session has multiple queries with the same name but different arguments.
        Parameters:
        shouldSearchParent - indicates whether parent should be searched if query not found.
        See Also:
        getQuery(String, List)
      • getSequencing

        public Sequencing getSequencing()
        INTERNAL: Return the Sequencing object used by the session.
      • getSessionForClass

        public AbstractSession getSessionForClass​(Class domainClass)
        INTERNAL: Return the session to be used for the class. Used for compatibility with the session broker.
      • getSessionLog

        public SessionLog getSessionLog()
        PUBLIC: Return the session log to which an accessor logs messages and SQL. If not set, this will default to a session log on a writer on System.out. To enable logging, logMessages must be turned on.
        Specified by:
        getSessionLog in interface Session
        See Also:
        setLoggingOff(boolean)
      • getTablePerTenantDescriptors

        public List<ClassDescriptor> getTablePerTenantDescriptors()
        INTERNAL: Return list of table per tenant multitenant descriptors.
      • getTablePerTenantQueries

        public List<DatabaseQuery> getTablePerTenantQueries()
        INTERNAL: Return list of table per tenant multitenant descriptors.
      • getTransactionMutex

        public ConcurrencyManager getTransactionMutex()
        INTERNAL: The transaction mutex ensure mutual exclusion on transaction across multiple threads.
      • hasBroker

        public boolean hasBroker()
        INTERNAL: Allow the session to be used from a session broker.
      • hasDescriptor

        public boolean hasDescriptor​(Class theClass)
        ADVANCED: Return true if a descriptor exists for the given class.
        Specified by:
        hasDescriptor in interface Session
      • hasExceptionHandler

        public boolean hasExceptionHandler()
        PUBLIC: Return if an exception handler is present.
        Specified by:
        hasExceptionHandler in interface Session
      • hasExternalTransactionController

        public boolean hasExternalTransactionController()
        PUBLIC: Used for JTA integration. If your application requires to have JTA control transactions instead of EclipseLink an external transaction controler must be specified. EclipseLink provides JTA controlers for JTA 1.0 and application servers.
        Specified by:
        hasExternalTransactionController in interface Session
        See Also:
        JTATransactionController
      • initializeIdentityMapAccessor

        public void initializeIdentityMapAccessor()
        INTERNAL: Set up the IdentityMapManager. This method allows subclasses of Session to override the default IdentityMapManager functionality.
      • insertObject

        public Object insertObject​(Object domainObject)
                            throws DatabaseException
        PUBLIC: Insert the object and all of its privately owned parts into the database. Insert should only be used if the application knows that the object is new, otherwise writeObject should be used. The insert operation can be customized through using an insert query.
        Throws:
        DatabaseException - if an error occurs on the database, these include constraint violations, security violations and general database errors.
        See Also:
        InsertObjectQuery, writeObject(Object)
      • internalExecuteQuery

        public Object internalExecuteQuery​(DatabaseQuery query,
                                           AbstractRecord databaseRow)
                                    throws DatabaseException
        INTERNAL: Return the results from exeucting the database query. The arguments should be a database row with raw data values. This method is provided to allow subclasses to change the default querying behavior. All querying goes through this method.
        Throws:
        DatabaseException
      • isBroker

        public boolean isBroker()
        INTERNAL: Returns true if the session is a session Broker.
      • isInBroker

        public boolean isInBroker()
        INTERNAL: Returns true if the session is in a session Broker.
      • isClassReadOnly

        public boolean isClassReadOnly​(Class theClass)
        PUBLIC: Return if the class is defined as read-only.
      • isClassReadOnly

        public boolean isClassReadOnly​(Class theClass,
                                       ClassDescriptor descriptor)
        INTERNAL: Return if the class is defined as read-only. PERF: Pass descriptor to avoid re-lookup.
      • isClientSession

        public boolean isClientSession()
        PUBLIC: Return if this session is a client session.
        Specified by:
        isClientSession in interface Session
      • isIsolatedClientSession

        public boolean isIsolatedClientSession()
        PUBLIC: Return if this session is an isolated client session.
      • isExclusiveIsolatedClientSession

        public boolean isExclusiveIsolatedClientSession()
        PUBLIC: Return if this session is an exclusive isolated client session.
      • isConnected

        public boolean isConnected()
        PUBLIC: Return if this session is connected to the database.
        Specified by:
        isConnected in interface Session
      • isDatabaseSession

        public boolean isDatabaseSession()
        PUBLIC: Return if this session is a database session.
        Specified by:
        isDatabaseSession in interface Session
      • isDistributedSession

        public boolean isDistributedSession()
        PUBLIC: Return if this session is a distributed session.
        Specified by:
        isDistributedSession in interface Session
      • isInProfile

        public boolean isInProfile()
        PUBLIC: Return if a profiler is being used.
        Specified by:
        isInProfile in interface Session
      • setIsInProfile

        public void setIsInProfile​(boolean inProfile)
        PUBLIC: Allow for user deactive a profiler
      • setIsInBroker

        public void setIsInBroker​(boolean isInBroker)
        INTERNAL: Set if this session is contained in a SessionBroker.
      • isFinalizersEnabled

        public boolean isFinalizersEnabled()
        PUBLIC: Return if this session's decendants should use finalizers. The allows certain finalizers such as in ClientSession to be enabled. These are disable by default for performance reasons.
        Specified by:
        isFinalizersEnabled in interface Session
      • registerFinalizer

        public void registerFinalizer()
        INTERNAL: Register a finalizer to release this session.
      • isHistoricalSession

        public boolean isHistoricalSession()
        INTERNAL: Return if this session is a historical session.
      • setIsFinalizersEnabled

        public void setIsFinalizersEnabled​(boolean isFinalizersEnabled)
        PUBLIC: Set if this session's decendants should use finalizers. The allows certain finalizers such as in ClientSession to be enabled. These are disable by default for performance reasons.
        Specified by:
        setIsFinalizersEnabled in interface Session
      • isInTransaction

        public boolean isInTransaction()
        PUBLIC: Return if the session is currently in the progress of a database transaction. Because nested transactions are allowed check if the transaction mutex has been aquired.
      • isJPAQueriesProcessed

        public boolean isJPAQueriesProcessed()
        INTERNAL: used to see if JPA Queries have been processed during initialization
      • isProtectedSession

        public boolean isProtectedSession()
        PUBLIC: Returns true if Protected Entities should be built within this session
      • isRemoteSession

        public boolean isRemoteSession()
        PUBLIC: Return if this session is remote.
        Specified by:
        isRemoteSession in interface Session
      • isRemoteUnitOfWork

        public boolean isRemoteUnitOfWork()
        PUBLIC: Return if this session is a unit of work.
        Specified by:
        isRemoteUnitOfWork in interface Session
      • isServerSession

        public boolean isServerSession()
        PUBLIC: Return if this session is a server session.
        Specified by:
        isServerSession in interface Session
      • isSessionBroker

        public boolean isSessionBroker()
        PUBLIC: Return if this session is a session broker.
        Specified by:
        isSessionBroker in interface Session
      • isSynchronized

        public boolean isSynchronized()
        INTERNAL: Return if this session is synchronized.
      • isUnitOfWork

        public boolean isUnitOfWork()
        PUBLIC: Return if this session is a unit of work.
        Specified by:
        isUnitOfWork in interface Session
      • logMessage

        public void logMessage​(String message)
        Log a untranslated message to the EclipseLink log at FINER level.
        Specified by:
        logMessage in interface Session
      • prepareDatabaseQuery

        public DatabaseQuery prepareDatabaseQuery​(DatabaseQuery query)
        INTERNAL: A call back to do session specific preparation of a query.

        The call back occurs soon before we clone the query for execution, meaning that if this method needs to clone the query then the caller will determine that it doesn't need to clone the query itself.

      • readAllObjects

        public Vector readAllObjects​(Class domainClass,
                                     String sqlString)
                              throws DatabaseException
        PUBLIC: Read all of the instances of the class from the database return through execution the SQL string. The SQL string must be a valid SQL select statement or selecting stored procedure call. This operation can be customized through using a ReadAllQuery. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
        Throws:
        DatabaseException
        See Also:
        ReadAllQuery
      • readAllObjects

        public Vector readAllObjects​(Class referenceClass,
                                     Call aCall)
                              throws DatabaseException
        PUBLIC: Read all the instances of the class from the database returned through execution the Call string. The Call can be an SQLCall or JPQLCall. example: session.readAllObjects(Employee.class, new SQLCall("SELECT * FROM EMPLOYEE"));
        Specified by:
        readAllObjects in interface Session
        Throws:
        DatabaseException
        See Also:
        Call
      • readObject

        public Object readObject​(Class domainClass,
                                 String sqlString)
                          throws DatabaseException
        PUBLIC: Read the first instance of the class from the database return through execution the SQL string. The SQL string must be a valid SQL select statement or selecting stored procedure call. This operation can be customized through using a ReadObjectQuery. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
        Throws:
        DatabaseException
        See Also:
        ReadObjectQuery
      • readObject

        public Object readObject​(Class domainClass,
                                 Call aCall)
                          throws DatabaseException
        PUBLIC: Read the first instance of the class from the database returned through execution the Call string. The Call can be an SQLCall or JPQLCall. example: session.readObject(Employee.class, new SQLCall("SELECT * FROM EMPLOYEE"));
        Specified by:
        readObject in interface Session
        Throws:
        DatabaseException
        See Also:
        SQLCall, JPQLCall
      • readObject

        public Object readObject​(Object object)
                          throws DatabaseException
        PUBLIC: Use the example object to consruct a read object query by the objects primary key. This will read the object from the database with the same primary key as the object or null if no object is found.
        Specified by:
        readObject in interface Session
        Throws:
        DatabaseException
      • refreshAndLockObject

        public Object refreshAndLockObject​(Object object)
                                    throws DatabaseException
        PUBLIC: Refresh the attributes of the object and of all of its private parts from the database. The object will be pessimisticly locked on the database for the duration of the transaction. If the object is already locked this method will wait until the lock is released. A no wait option is available through setting the lock mode.
        Throws:
        DatabaseException
        See Also:
        refreshAndLockObject(Object, short)
      • refreshAndLockObject

        public Object refreshAndLockObject​(Object object,
                                           short lockMode)
                                    throws DatabaseException
        PUBLIC: Refresh the attributes of the object and of all of its private parts from the database. The object will be pessimisticly locked on the database for the duration of the transaction.

        Lock Modes: ObjectBuildingQuery.NO_LOCK, LOCK, LOCK_NOWAIT

        Throws:
        DatabaseException
      • refreshObject

        public Object refreshObject​(Object object)
                             throws DatabaseException
        PUBLIC: Refresh the attributes of the object and of all of its private parts from the database. This can be used to ensure the object is up to date with the database. Caution should be used when using this to make sure the application has no un commited changes to the object.
        Specified by:
        refreshObject in interface Session
        Throws:
        DatabaseException
      • release

        public void release()
        PUBLIC: Release the session. This does nothing by default, but allows for other sessions such as the ClientSession to do something.
        Specified by:
        release in interface Session
      • releaseUnitOfWork

        public void releaseUnitOfWork​(UnitOfWorkImpl unitOfWork)
        INTERNAL: Release the unit of work, if lazy release the connection.
      • removeProperty

        public void removeProperty​(String property)
        PUBLIC: Remove the user defined property.
        Specified by:
        removeProperty in interface Session
      • removeQuery

        public void removeQuery​(String queryName,
                                Vector argumentTypes)
        PUBLIC: Remove the specific query with the given queryName and argumentTypes.
      • rollbackExternalTransaction

        protected boolean rollbackExternalTransaction()
        PROTECTED: Attempts to rollback the running internally started external transaction. Returns true only in one case - extenal transaction has been internally rolled back during this method call: wasJTSTransactionInternallyStarted()==true in the beginning of this method and wasJTSTransactionInternallyStarted()==false in the end of this method.
      • rollbackTransaction

        public void rollbackTransaction()
                                 throws DatabaseException,
                                        ConcurrencyException
        PUBLIC: Rollback the active database transaction. This allows a group of database modification to be commited or rolledback as a unit. All writes/deletes will be sent to the database be will not be visible to other users until commit. Although databases do not allow nested transaction, EclipseLink supports nesting through only committing to the database on the outer commit.
        Throws:
        DatabaseException - if the database connection is lost or the rollback fails.
        ConcurrencyException - if this session is not within a transaction.
      • setAccessor

        public void setAccessor​(Accessor accessor)
        INTERNAL: Set the accessor.
      • setBroker

        public void setBroker​(AbstractSession broker)
        INTERNAL: Allow the session to be used from a session broker.
      • setCommitManager

        public void setCommitManager​(CommitManager commitManager)
        INTERNAL: The commit manager is used to resolve referncial integrity on commits of multiple objects.
      • setInjectionManager

        public void setInjectionManager​(InjectionManager injectionManager)
      • setEventManager

        public void setEventManager​(SessionEventManager eventManager)
        INTERNAL: Set the event manager. The event manager can be used to register for various session events.
      • setExceptionHandler

        public void setExceptionHandler​(ExceptionHandler exceptionHandler)
        PUBLIC: Set the exceptionHandler. Exception handler can catch errors that occur on queries or during database access.
        Specified by:
        setExceptionHandler in interface Session
      • setIntegrityChecker

        public void setIntegrityChecker​(IntegrityChecker integrityChecker)
        PUBLIC: set the integrityChecker. IntegrityChecker holds all the ClassDescriptor Exceptions.
        Specified by:
        setIntegrityChecker in interface Session
      • setJPAQueriesProcessed

        public void setJPAQueriesProcessed​(boolean jpaQueriesProcessed)
        INTERNAL: used to set if JPA Queries have been processed during initialization
      • setLog

        public void setLog​(Writer log)
        PUBLIC: Set the writer to which an accessor writes logged messages and SQL. If not set, this reference defaults to a writer on System.out. To enable logging logMessages() is used.
        Specified by:
        setLog in interface Session
        See Also:
        setLoggingOff(boolean)
      • setLogin

        public void setLogin​(DatabaseLogin login)
        PUBLIC: Set the login.
      • setLogin

        public void setLogin​(Login login)
        PUBLIC: Set the login.
      • setDatasourceLogin

        public void setDatasourceLogin​(Login login)
        PUBLIC: Set the login.
      • setName

        public void setName​(String name)
        PUBLIC: Set the name of the session. This is used with the session broker.
        Specified by:
        setName in interface Session
      • setNumberOfActiveUnitsOfWork

        protected void setNumberOfActiveUnitsOfWork​(int numberOfActiveUnitsOfWork)
      • setPessimisticLockTimeoutDefault

        public void setPessimisticLockTimeoutDefault​(Integer pessimisticLockTimeoutDefault)
        PUBLIC: Set the default pessimistic lock timeout value. This value will be used to set the WAIT clause of a SQL SELECT FOR UPDATE statement. It defines how long EcliseLink should wait for a lock on the database row before aborting.
      • setPessimisticLockTimeoutUnitDefault

        public void setPessimisticLockTimeoutUnitDefault​(TimeUnit pessimisticLockTimeoutUnitDefault)
      • setQueryTimeoutDefault

        public void setQueryTimeoutDefault​(int queryTimeoutDefault)
        PUBLIC: Set the default query timeout for this session. This timeout will apply to any queries that do not have a timeout set, and that do not have a default timeout defined in their descriptor.
        Specified by:
        setQueryTimeoutDefault in interface Session
      • setQueryTimeoutUnitDefault

        public void setQueryTimeoutUnitDefault​(TimeUnit queryTimeoutUnitDefault)
        Description copied from interface: Session
        PUBLIC: Set the default query timeout units for this session. This timeout unit will apply to any queries that do not have a unit value set, and that do not have a default timeout unit defined in their descriptor.
        Specified by:
        setQueryTimeoutUnitDefault in interface Session
      • setProfiler

        public void setProfiler​(SessionProfiler profiler)
        PUBLIC: Set the profiler for the session. This allows for performance operations to be profiled.
        Specified by:
        setProfiler in interface Session
      • setProject

        public void setProject​(Project project)
        INTERNAL: Set the project, the project holds configuration information including the descriptors.
      • setProperties

        public void setProperties​(Map<String,​Object> propertiesMap)
        INTERNAL: Set the user defined properties by shallow copying the propertiesMap.
        Parameters:
        propertiesMap -
      • setProperty

        public void setProperty​(String propertyName,
                                Object propertyValue)
        PUBLIC: Allow for user defined properties.
        Specified by:
        setProperty in interface Session
      • setSessionLog

        public void setSessionLog​(SessionLog sessionLog)
        PUBLIC: Set the session log to which an accessor logs messages and SQL. If not set, this will default to a session log on a writer on System.out. To enable logging, log level can not be OFF. Also set a backpointer to this session in SessionLog.
        Specified by:
        setSessionLog in interface Session
        See Also:
        logMessage(String)
      • setSynchronized

        public void setSynchronized​(boolean synched)
        INTERNAL: Set isSynchronized flag to indicate that this session is synchronized. This method should only be called by setSynchronized methods of derived classes.
      • setTransactionMutex

        protected void setTransactionMutex​(ConcurrencyManager transactionMutex)
      • setWasJTSTransactionInternallyStarted

        public void setWasJTSTransactionInternallyStarted​(boolean wasJTSTransactionInternallyStarted)
        INTERNAL: Return if a JTS transaction was started by the session. The session will start a JTS transaction if a unit of work or transaction is begun without a JTS transaction present.
      • shouldLogMessages

        public boolean shouldLogMessages()
        PUBLIC: Return if logging is enabled (false if log level is OFF)
        Specified by:
        shouldLogMessages in interface Session
      • startOperationProfile

        public void startOperationProfile​(String operationName,
                                          DatabaseQuery query,
                                          int weight)
        INTERNAL: Start the operation timing.
      • toString

        public String toString()
        Print the connection status with the session.
        Overrides:
        toString in class Object
      • unwrapObject

        public Object unwrapObject​(Object proxy)
        INTERNAL: Unwrap the object if required. This is used for the wrapper policy support and EJB.
      • updateObject

        public Object updateObject​(Object domainObject)
                            throws DatabaseException,
                                   OptimisticLockException
        PUBLIC: Update the object and all of its privately owned parts in the database. Update should only be used if the application knows that the object is new, otherwise writeObject should be used. The update operation can be customized through using an update query.
        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.
        See Also:
        UpdateObjectQuery, writeObject(Object)
      • validateCache

        public void validateCache()
        ADVANCED: This can be used to help debugging an object identity problem. An object identity problem is when an object in the cache references an object not in the cache. This method will validate that all cached objects are in a correct state.
        Specified by:
        validateCache in interface Session
      • validateQuery

        public void validateQuery​(DatabaseQuery query)
        INTERNAL: This method will be used to update the query with any settings required For this session. It can also be used to validate execution.
      • verifyDelete

        public boolean verifyDelete​(Object domainObject)
        TESTING: This is used by testing code to ensure that a deletion was successful.
      • wasJTSTransactionInternallyStarted

        public boolean wasJTSTransactionInternallyStarted()
        INTERNAL: Return if a JTS transaction was started by the session. The session will start a JTS transaction if a unit of work or transaction is begun without a JTS transaction present.
      • wrapObject

        public Object wrapObject​(Object implementation)
        INTERNAL: Wrap the object if required. This is used for the wrapper policy support and EJB.
      • writeAllObjectsWithChangeSet

        protected void writeAllObjectsWithChangeSet​(UnitOfWorkChangeSet uowChangeSet)
                                             throws DatabaseException,
                                                    OptimisticLockException
        INTERNAL: Write all of the objects and all of their privately owned parts in the database. The allows for a group of new objects to be commited as a unit. The objects will be commited through a single transactions and any foreign keys/circular references between the objects will be resolved.
        Throws:
        DatabaseException
        OptimisticLockException
      • writeObject

        public Object writeObject​(Object domainObject)
                           throws DatabaseException,
                                  OptimisticLockException
        PUBLIC: Write the object and all of its privately owned parts in the database. Write will determine if an insert or an update should be done, it may go to the database to determine this (by default will check the identity map). The write operation can be customized through using an write query.
        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.
        See Also:
        WriteObjectQuery, insertObject(Object), updateObject(Object)
      • writesCompleted

        public void writesCompleted()
        INTERNAL: This method notifies the accessor that a particular sets of writes has completed. This notification can be used for such thing as flushing the batch mechanism
      • processCommand

        public void processCommand​(Object command)
        INTERNAL: RemoteCommandManager method. This is a required method in order to implement the CommandProcessor interface. Process the remote command from the RCM. The command may have come from any remote session or application. Since this is a EclipseLink session we can always assume that the object that we receive here will be a Command object.
        Specified by:
        processCommand in interface CommandProcessor
        Parameters:
        command - Application formatted command to be processed
      • processJPAQueries

        public void processJPAQueries()
        INTERNAL: Process the JPA named queries into EclipseLink Session queries. This method is called after descriptor initialization. Temporarily made public for ODI. Should not be used elsewhere.
      • processJPAQuery

        protected void processJPAQuery​(DatabaseQuery jpaQuery)
        INTERNAL: Process the JPA named query into an EclipseLink Session query. This method is called after descriptor initialization.
      • getCommandManager

        public CommandManager getCommandManager()
        PUBLIC: Return the CommandManager that allows this session to act as a CommandProcessor and receive or propagate commands from/to the EclipseLink cluster.
        Specified by:
        getCommandManager in interface CommandProcessor
        Returns:
        The CommandManager instance that controls the remote command service for this session
        See Also:
        CommandManager
      • setCommandManager

        public void setCommandManager​(CommandManager mgr)
        ADVANCED: Set the CommandManager that allows this session to act as a CommandProcessor and receive or propagate commands from/to the EclipseLink cluster.
        Specified by:
        setCommandManager in interface CommandProcessor
        Parameters:
        mgr - The CommandManager instance to control the remote command service for this session
        See Also:
        CommandManager
      • shouldPropagateChanges

        public boolean shouldPropagateChanges()
        PUBLIC: Return whether changes should be propagated to other sessions or applications in a EclipseLink cluster through the Remote Command Manager mechanism. In order for this to occur the CommandManager must be set.
        Returns:
        True if propagation is set to occur, false if not
        See Also:
        setCommandManager(CommandManager)
      • setShouldPropagateChanges

        public void setShouldPropagateChanges​(boolean choice)
        ADVANCED: Set whether changes should be propagated to other sessions or applications in a EclipseLink cluster through the Remote Command Manager mechanism. In order for this to occur the CommandManager must be set.
        Parameters:
        choice - If true (and the CommandManager is set) then propagation will occur
        See Also:
        setCommandManager(CommandManager)
      • shouldLogMessages

        public boolean shouldLogMessages​(int logLevel)
        INTERNAL: RemoteCommandManager method. This is a required method in order to implement the CommandProcessor interface. Return true if a message at the specified log level would be logged given the log level setting of this session. This can be used by the CommandManager to know whether it should even bother to create the localized strings and call the logMessage method, or if it would only find that the message would not be logged because the session level does not permit logging. The log level passed in will be one of the constants LOG_ERROR, LOG_WARNING, LOG_INFO, and LOG_DEBUG defined in the CommandProcessor interface.
        Specified by:
        shouldLogMessages in interface CommandProcessor
        Parameters:
        logLevel - A log constant that is one of LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG
        Returns:
        True if a message at the specified level should be logged and false if it should not
      • logMessage

        public void logMessage​(int logLevel,
                               String message)
        INTERNAL: RemoteCommandManager method. This is a required method in order to implement the CommandProcessor interface. Log the specified message string at the specified level if it should be logged given the log level setting in this session. The log level passed in will be one of the constants LOG_ERROR, LOG_WARNING, LOG_INFO, and LOG_DEBUG defined in the CommandProcessor interface.
        Specified by:
        logMessage in interface CommandProcessor
        Parameters:
        logLevel - A log constant that is one of LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG
        message - The message String that is to be logged
      • getLogLevel

        public int getLogLevel​(String category)
        PUBLIC:

        Return the log level

        Specified by:
        getLogLevel in interface Session
        Parameters:
        category - the string representation of a EclipseLink category, e.g. "sql", "transaction" ...

        Returns:
        the log level

        See Also:
        SessionLog
      • getLogLevel

        public int getLogLevel()
        PUBLIC:

        Return the log level

        Specified by:
        getLogLevel in interface Session
        Returns:
        the log level

        See Also:
        SessionLog
      • shouldDisplayData

        public boolean shouldDisplayData()
        PUBLIC: Return true if SQL logging should log visible bind parameters. If the shouldDisplayData is not set, check the session log level and return true for a level greater than CONFIG.
      • shouldLog

        public boolean shouldLog​(int level,
                                 String category)
        PUBLIC:

        Check if a message of the given level would actually be logged.

        Specified by:
        shouldLog in interface Session
        Parameters:
        level - the log request level
        category - the string representation of a EclipseLink category
        Returns:
        true if the given message level will be logged
        See Also:
        SessionLog
      • log

        public void log​(int level,
                        String category,
                        String message)
        PUBLIC:

        Log a message with level and category that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        category - the string representation of a EclipseLink category.

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object param)
        PUBLIC:

        Log a message with level, category and a parameter that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        category - the string representation of a EclipseLink category.

        param - a parameter of the message

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object param1,
                        Object param2)
        PUBLIC:

        Log a message with level, category and two parameters that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        category - the string representation of a EclipseLink category.

        param1 - a parameter of the message

        param2 - second parameter of the message

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object param1,
                        Object param2,
                        Object param3)
        PUBLIC:

        Log a message with level, category and three parameters that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        category - the string representation of a EclipseLink category.

        param1 - a parameter of the message

        param2 - second parameter of the message

        param3 - third parameter of the message

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object[] params)
        PUBLIC:

        Log a message with level, category and an array of parameters that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        category - the string representation of a EclipseLink category.

        params - array of parameters to the message

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object[] params,
                        Accessor accessor)
        PUBLIC:

        Log a message with level, category, parameters and accessor that needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        params - array of parameters to the message

        accessor - the connection that generated the log entry

        category - the string representation of a EclipseLink category.

      • log

        public void log​(int level,
                        String category,
                        String message,
                        Object[] params,
                        Accessor accessor,
                        boolean shouldTranslate)
        PUBLIC:

        Log a message with level, category, parameters and accessor. shouldTranslate determines if the message needs to be translated.

        Parameters:
        level - the log request level value

        message - the string message

        params - array of parameters to the message

        accessor - the connection that generated the log entry

        category - the string representation of a EclipseLink category.

        shouldTranslate - true if the message needs to be translated.

      • logThrowable

        public void logThrowable​(int level,
                                 String category,
                                 Throwable throwable)
        PUBLIC:

        Log a throwable with level and category.

        Parameters:
        level - the log request level value

        category - the string representation of a EclipseLink category.

        throwable - a Throwable

      • severe

        public void severe​(String message,
                           String category)
        PUBLIC:

        This method is called when a severe level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • warning

        public void warning​(String message,
                            String category)
        PUBLIC:

        This method is called when a warning level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • info

        public void info​(String message,
                         String category)
        PUBLIC:

        This method is called when a info level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • config

        public void config​(String message,
                           String category)
        PUBLIC:

        This method is called when a config level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • fine

        public void fine​(String message,
                         String category)
        PUBLIC:

        This method is called when a fine level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • finer

        public void finer​(String message,
                          String category)
        PUBLIC:

        This method is called when a finer level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • finest

        public void finest​(String message,
                           String category)
        PUBLIC:

        This method is called when a finest level message needs to be logged. The message will be translated

        Parameters:
        message - the message key

      • releaseReadConnection

        public void releaseReadConnection​(Accessor connection)
        INTERNAL:
      • copyDescriptorsFromProject

        public void copyDescriptorsFromProject()
        INTERNAL: Copies descriptors cached on the Project. Used after Project.descriptors has been reset by addDescriptor(s) when the session is connected.
      • copyDescriptorNamedQueries

        public void copyDescriptorNamedQueries​(boolean allowSameQueryNameDiffArgsCopyToSession)
        INTERNAL: This method will be used to copy all EclipseLink named queries defined in descriptors into the session.
        Parameters:
        allowSameQueryNameDiffArgsCopyToSession - if the value is true, it allow multiple queries of the same name but different arguments to be copied to the session.
      • postAcquireConnection

        public void postAcquireConnection​(Accessor accessor)
        INTERNAL: This method rises appropriate for the session event(s) right after connection is acquired.
      • preReleaseConnection

        public void preReleaseConnection​(Accessor accessor)
        INTERNAL: This method rises appropriate for the session event(s) right before the connection is released.
      • priviledgedExecuteNonSelectingCall

        public int priviledgedExecuteNonSelectingCall​(Call call)
                                               throws DatabaseException
        INTERNAL: Execute the call on the database. Calling this method will bypass a global setting to disallow native SQL queries. (set by default when one Entity is marked as multitenant) The row count is returned. The call can be a stored procedure call, SQL call or other type of call.

        Example:

        session.executeNonSelectingCall(new SQLCall("Delete from Employee"), true);

        Throws:
        DatabaseException
        See Also:
        priviledgedExecuteSelectingCall(Call)
      • priviledgedExecuteSelectingCall

        public Vector priviledgedExecuteSelectingCall​(Call call)
                                               throws DatabaseException
        INTERNAL: Execute the call on the database and return the result. Calling this method will bypass a global setting to disallow native SQL queries. (set by default when one Entity is marked as multitenant) The call must return a value, if no value is return executeNonSelectCall must be used. The call can be a stored procedure call, SQL call or other type of call. A vector of database rows is returned, database row implements Java 2 Map which should be used to access the data.

        Example:

        session.executeSelectingCall(new SQLCall("Select * from Employee");

        Throws:
        DatabaseException
        See Also:
        priviledgedExecuteNonSelectingCall(Call)
      • isExclusiveConnectionRequired

        public boolean isExclusiveConnectionRequired()
        INTERNAL: This method is called in case externalConnectionPooling is used. If returns true, accessor used by the session keeps its connection open until released by the session.
      • setDefaultReferenceMode

        public void setDefaultReferenceMode​(ReferenceMode defaultReferenceMode)
        Stores the default Session wide reference mode that a UnitOfWork will use when referencing managed objects.
        Specified by:
        setDefaultReferenceMode in interface Session
        See Also:
        ReferenceMode
      • load

        public void load​(Object objectOrCollection,
                         AttributeGroup group)
        This method will load the passed object or collection of objects using the passed AttributeGroup. In case of collection all members should be either objects of the same mapped type or have a common inheritance hierarchy mapped root class. The AttributeGroup should correspond to the object type.
        Parameters:
        objectOrCollection -
      • load

        public void load​(Object objectOrCollection,
                         AttributeGroup group,
                         ClassDescriptor referenceDescriptor,
                         boolean fromFetchGroup)
        This method will load the passed object or collection of objects using the passed AttributeGroup. In case of collection all members should be either objects of the same mapped type or have a common inheritance hierarchy mapped root class. The AttributeGroup should correspond to the object type.
        Parameters:
        objectOrCollection -
      • setPartitioningPolicy

        public void setPartitioningPolicy​(PartitioningPolicy partitioningPolicy)
        PUBLIC: Set the session's partitioning policy. A PartitioningPolicy is used to partition, load-balance or replicate data across multiple difference databases or across a database cluster such as Oracle RAC. Partitioning can provide improved scalability by allowing multiple database machines to service requests.
        Specified by:
        setPartitioningPolicy in interface Session
      • getRefreshMetadataListener

        public MetadataRefreshListener getRefreshMetadataListener()
        INTERNAL: This currently only used by JPA with RCM to force a refresh of the metadata used within EntityManagerFactoryWrappers
      • setRefreshMetadataListener

        public void setRefreshMetadataListener​(MetadataRefreshListener metadatalistener)
      • isConcurrent

        public boolean isConcurrent()
        ADVANCED: Return if the session enables concurrent processing. Concurrent processing allow certain processing to be done on seperate threads. This can result in improved performance. This will use the session's server platform's thread pool.
      • setIsConcurrent

        public void setIsConcurrent​(boolean isConcurrent)
        ADVANCED: Set if the session enables concurrent processing. Concurrent processing allow certain processing to be done on seperate threads. This can result in improved performance. This will use the session's server platform's thread pool.
      • setShouldOptimizeResultSetAccess

        public void setShouldOptimizeResultSetAccess​(boolean shouldOptimizeResultSetAccess)
        ADVANCED: Set to indicate whether ObjectLevelReadQuery should by default use ResultSet Access optimization. If not set then parent's flag is used, is none set then ObjectLevelReadQuery.isResultSetAccessOptimizedQueryDefault is used. If the optimization specified by the session is ignored if incompatible with other query settings.
      • shouldOptimizeResultSetAccess

        public boolean shouldOptimizeResultSetAccess()
        ADVANCED: Indicates whether ObjectLevelReadQuery should by default use ResultSet Access optimization. Optimization specified by the session is ignored if incompatible with other query settings.
      • setTolerateInvalidJPQL

        public void setTolerateInvalidJPQL​(boolean b)
        ADVANCED: Indicates whether an invalid NamedQuery will be tolerated at init time. Default is false.
      • shouldTolerateInvalidJPQL

        public boolean shouldTolerateInvalidJPQL()
        ADVANCED: Indicates whether an invalid NamedQuery will be tolerated at init time. Default is false.