Skip Headers

# Acquiring a Historical Session

Previous

Next

After you configure TopLink to access historical data (see "Historical Session Configuration Overview"), you can query historical data using any session type.

When you query historical data using a regular client session or database session, you must always set `ObjectLevelReadQuery` method `maintainCache` to `false` in order to prevent old (historical) data from corrupting the session cache. However, you can query both current and historical object versions.

As a convenience, TopLink provides a historical session to simplify this process. When you query historical data using a historical session, you do not need to set `ObjectLevelReadQuery` method `maintainCache` to `false`. However, you can query objects only as of the specified time.

Before you can acquire a historical session, you must first use the session manager to acquire a server session.

To acquire a historical session, use `Server` method `acquireHistoricalSession` passing in an `AsOfClause`.

The `AsOfClause` specifies a point in time that applies to all queries and expressions subsequently executed on the historical session. The historical session's cache is a read-only snapshot of object versions as of the specified time. Its cache is isolated from its parent server session's shared object cache.