Skip Headers

# Providing Read Access

Previous

Next

To read objects from the database, the client must first acquire a client session from the server session. Acquiring a client session gives the client access to the session cache and the database through the server session. The server session behaves as follows:

- If the object or data is in the session cache, then the server session returns the information back to the client.

- If the object or data is not in the cache, then the server session reads the information from the database and stores the object in the session cache. The objects are then available for retrieval from the cache.

Because a server session processes each client request in a separate thread, this enables multiple clients to access the database connection pool concurrently.

Figure: Multiple Client Sessions Reading the Database Using the Server Session illustrates how multiple clients read from the database using the server session.

Multiple Client Sessions Reading the Database Using the Server Session

Description of "Multiple Client Sessions Reading the Database Using the Server Session"

To read objects from the database using a client session, do the following:

1. Acquire a `Session` from the `Server`:

       Server server =
           (Server) SessionManager.getManager().getSession(
               sessionName, MyServerSession.class.getClassLoader()
           );
       Session clientSession = (Session) server.acquireClientSession();

   For more information, see "Acquiring and Using Sessions at Run Time".

2. Use the `Session` object to perform read operations (for more information, see "Understanding TopLink Queries" and "Understanding TopLink Expressions").

   Note: Oracle recommends that you do not use the Server session object directly to read objects from the database.