Skip Headers

# Isolated Client Session Life Cycle

Previous

Next

This section provides an overview of the key phases in the life cycle of an isolated session, including the following:

- Setup required before using an isolated session

- Interaction among isolated session objects

- Clean-up required after using an isolated session

To enable the life cycle of an isolated session, use this procedure:

1. Prepare VPD configuration in the database.

2. Configure your project and session:

   - Designate descriptors as isolated (see "Configuring Cache Isolation at the Descriptor Level").

   - Configure your server session to allocate exclusive connections (see "Configuring Connection Policy").

   - Implement session event listeners for the required connection events

     - If you are using Oracle Database proxy authentication (see "Oracle Database Proxy Authentication"), see "NoRowsModifiedSessionEvent Event Handler".

     - If you are not using Oracle Database proxy authentication, see "PostAcquireExclusiveConnection Event Handler", "PreReleaseExclusiveConnection Event Handler", and "NoRowsModifiedSessionEvent Event Handler"

     Note: You must add these session event listeners to the server session from which you acquire your isolated client session. You cannot add them to the isolated client session itself. For more information, see "Configuring Session Event Listeners"

   - Implement exception handlers for the appropriate exceptions (see "ValidationException Handler").

3. Acquire an isolated session:

   - If you are using Oracle Database proxy authentication (see "Oracle Database Proxy Authentication"):

         Session myIsolatedClientSession = server.acquireClientSession();

     Because you configured one or more descriptors as isolated, `myIsolatedClientSession` is an isolated session with an exclusive connection.

   - If you are not using Oracle Database proxy authentication:

         ConnectionPolicy myConnPolicy =
             (ConnectionPolicy)server.getDefaultConnectionPolicy().clone();
         myConnectionPolicy.setProperty("credentials", myUserCredentials);
         Session myIsolatedClientSession =
             server.acquireClientSession(myConnectionPolicy);

     Set the user's credentials as appropriate properties on `myConnectionPolicy`. Because you configured one or more descriptors as isolated, `myIsolatedClientSession` is an isolated session with an exclusive connection.

   The TopLink runtime raises a `SessionEvent.PostAcquireExclusiveConnection` event handled by your `SessionEventListener` (see "PostAcquireExclusiveConnection Event Handler").

4. Use `myIsolatedClientSession` to interact with the database.

   If the TopLink runtime raises a `SessionEvent.NoRowsModified` event, it is handled by your `SessionEventListener` (see "NoRowsModifiedSessionEvent Event Handler").

5. When you are finished using `myIsolatedClientSession`, release the isolated session:

       myIsolatedClientSession.release();

   The TopLink runtime prepares to destroy the isolated cache and to close the exclusive connection associated with this isolated session.

   The TopLink runtime raises a `SessionEvent.PreReleaseExclusiveConnection` event handled by your `SessionEventListener` (see "PreReleaseExclusiveConnection Event Handler").

6. Repeat steps 3 to 5 (as required) until the application exits.