Skip Headers

# Handling Cursor and Stream Query Results

Previous

Next

Cursors and streams are related mechanisms that let you work with large result sets efficiently. See "Stream and Cursor Query Results" for more information.

Table: Stream and Cursor Query Result Options lists the methods that TopLink provides for all subclasses of `DataReadQuery` and `ReadAllQuery` that you can use to make your query return its results as a cursor or stream.

Stream and Cursor Query Result Options

Method | Query Returns | Description
--- | --- | ---
`useScrollableCursor` | `ScrollableCursor` | Allows you access a database result set cursor, allowing you to move forward and backward through the result set.
`useCursoredStream` | `CursoredStream` | Allows you to access results one at a time in sequence, as results become available to the underlying database result set cursor.

Using a `ScrollableCursor` or `CursoredStream` combines the features of a TopLink with the ability of the database to cursor data, and breaks up the result set into smaller, more manageable pieces.

The behavior of a query that uses a `ScrollableCursor` or `CursoredStream` differs from other queries in that the elements requested by the client are sent to the client.

This section describes the following:

- Cursors and Java Iterators

- Java Streams

- Optimizing Streams

- Using Cursors and Streams With EJB Finders