class LOBStateTracker extends java.lang.Object
A LOB's state is either unpublished or published. When a LOB is published, it
means that the end-user has been given a reference to the LOB object. This
implies that the LOB cannot be automatically freed/released when the
result set position changes (i.e. typically
rs.next()), because the
LOB object must be kept valid/alive until the transaction is ended or the
LOB object is explicitly freed.
This class covers two types of functionality regarding LOBs;
The tracker has a notion of current row. The current row is changed by
checkCurrentRow. The owner of the tracker
is repsonsible for invoking the method at the correct time, and only when
the cursor is positioned on a valid data row. The method must be invoked
before the cursor changes the position. Note that calling the method
checkCurrentRow ignore all
LOBs on the subsequent call.
|Modifier and Type||Field and Description|
Instance to use when there are no LOBs in the result set, or when the server doesn't support locators.
|Constructor and Description|
Creates a LOB state tracker for the specified configuration.
|Modifier and Type||Method and Description|
Checks the current row, updating state and releasing locators on the server as required.
Discards all recorded dynamic state about LOBs.
Marks the specified column of the current row as published, which implies that the tracker should not release the associated locator.
public static final LOBStateTracker NO_OP_TRACKER
LOBStateTracker(int lobIndexes, boolean isBlob, boolean doRelease)
lobIndexes- the 1-based indexes of the LOB columns
isBlob- whether the LOB is a Blob or a Clob
doRelease- whether locators shall be released
void checkCurrentRow(Cursor cursor) throws SqlException
This method should only be called once per valid row in the result set.
cursor- the cursor object to use for releasing the locators
SqlException- if releasing the locators on the server fails
Typically called after connection commit or rollback, as those operations will release all locators on the server automatically. There is no need to release them from the client side in this case.
void markAsPublished(int index)
Columns must be marked as published when a LOB object is created on the client, to avoid releasing the corresponding locator too early.
index- 1-based column index