Class ClientSession

    • Method Detail

      • 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 and releases accessor.
        Overrides:
        releaseJTSConnection in class AbstractSession
      • basicCommitTransaction

        public void basicCommitTransaction()
        INTERNAL: This is internal to the unit of work and should not be called otherwise.
        Overrides:
        basicCommitTransaction in class AbstractSession
      • basicRollbackTransaction

        public void basicRollbackTransaction()
        INTERNAL: This is internal to the unit of work and should not be called otherwise.
        Overrides:
        basicRollbackTransaction in class AbstractSession
      • executeCall

        public Object executeCall​(Call call,
                                  AbstractRecord translationRow,
                                  DatabaseQuery query)
                           throws DatabaseException
        INTERNAL: Execute the call on the correct connection accessor. Outside of a transaction the server session's read connection pool is used. In side a transaction, or for exclusive sessions the write connection is used. For partitioning there may be multiple write connections.
        Overrides:
        executeCall in class AbstractSession
        Throws:
        DatabaseException
      • getAccessors

        public Collection<Accessor> getAccessors()
        INTERNAL: Return the write connections if in a transaction. These may be empty/null until the first query has been executed inside the transaction. This should only be called within a transaction. If outside of a transaction it will return null (unless using an exclusive connection).
        Overrides:
        getAccessors in class AbstractSession
      • getAccessor

        public Accessor getAccessor()
        INTERNAL: This should normally not be used, getAccessors() should be used to support partitioning. To maintain backward compatibility, and to support certain cases that required a default accessor, if inside a transaction, then a default connection will be allocated. This is required for sequencing, and JPA connection unwrapping, and ordt mappings. Outside of a transaction, to maintain backward compatibility the server session's accessor will be returned.
        Overrides:
        getAccessor in class AbstractSession
      • getConnectionPolicy

        public ConnectionPolicy getConnectionPolicy()
        ADVANCED: This method will return the connection policy that was used during the acquisition of this client session. The properties within the ConnectionPolicy may be used when acquiring an exclusive connection for an IsolatedSession.
      • 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.
        Overrides:
        getParentIdentityMapSession in class AbstractSession
        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
      • getProperty

        public Object getProperty​(String name)
        Search for and return the user defined property from this client session, if it not found then search for the property from parent.
        Specified by:
        getProperty in interface Session
        Overrides:
        getProperty in class AbstractSession
      • 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.

        Overrides:
        getExecutionSession in class AbstractSession
        Parameters:
        query - may store session name or reference class for brokers case
        Returns:
        a session with a live accessor
      • getQuery

        public DatabaseQuery getQuery​(String name)
        INTERNAL: Was PUBLIC: customer will be redirected to Session. 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
        Overrides:
        getQuery in class AbstractSession
      • initializeSequencing

        public void initializeSequencing()
        INTERNAL: was ADVANCED: Creates sequencing object for the session. Typically there is no need for the user to call this method - it is called from the constructor.
      • getSequencing

        public Sequencing getSequencing()
        INTERNAL: Return the Sequencing object used by the session. Lazy init sequencing to defer from client session creation to improve creation performance.
        Overrides:
        getSequencing in class AbstractSession
      • 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.

        Overrides:
        getSessionTypeString in class AbstractSession
      • getWriteConnections

        public Map<String,​Accessor> getWriteConnections()
        INTERNAL: Return the map of write connections. Multiple connections can be used for data partitioning and replication. The connections are keyed by connection pool name.
      • getWriteConnection

        public Accessor getWriteConnection()
        INTERNAL: Return the connection to be used for database modification.
      • hasWriteConnection

        public boolean hasWriteConnection()
        INTERNAL: Return if this session has been connected.
      • initializeIdentityMapAccessor

        public void initializeIdentityMapAccessor()
        INTERNAL: Set up the IdentityMapManager. This method allows subclasses of Session to override the default IdentityMapManager functionality.
        Overrides:
        initializeIdentityMapAccessor in class AbstractSession
      • isActive

        public boolean isActive()
        INTERNAL: Was PUBLIC: customer will be redirected to Session. Return if the client session is active (has not been released).
      • isConnected

        public boolean isConnected()
        INTERNAL: Was PUBLIC: customer will be redirected to Session. Return if this session has been connected to the database.
        Specified by:
        isConnected in interface Session
        Overrides:
        isConnected in class AbstractSession
      • release

        public void release()
                     throws DatabaseException
        INTERNAL: Was PUBLIC: customer will be redirected to Session. Release the client session. This releases the client session back to it server. Normally this will logout of the client session's connection, and allow the client session to garbage collect.
        Specified by:
        release in interface Session
        Overrides:
        release in class AbstractSession
        Throws:
        DatabaseException
      • releaseWriteConnection

        protected void releaseWriteConnection()
        INTERNAL: This is internal to the unit of work and should not be called otherwise.
      • setConnectionPolicy

        public void setConnectionPolicy​(ConnectionPolicy connectionPolicy)
        INTERNAL: Set the connection policy.
      • setIsActive

        protected void setIsActive​(boolean isActive)
        INTERNAL: Set if the client session is active (has not been released).
      • setParent

        protected void setParent​(ServerSession parent)
        INTERNAL: Set the parent. This is a server session.
      • addWriteConnection

        public Accessor addWriteConnection​(String poolName,
                                           Accessor writeConnection)
        INTERNAL: Add the connection to the client session. Multiple connections are supported to allow data partitioning and replication. The accessor is returned, as if detected to be dead it may be replaced.
      • setWriteConnections

        public void setWriteConnections​(Map<String,​Accessor> writeConnections)
        INTERNAL: Set the connection to be used for database modification.
      • setWriteConnection

        public void setWriteConnection​(Accessor writeConnection)
        INTERNAL: Set the connection to be used for database modification.
      • 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.
        Overrides:
        isExclusiveConnectionRequired in class AbstractSession