Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


cursor

Use eclipselink.cursor to configure the query to return a CursoredStream.


Values

Table 4-5 describes this persistence property's values.

Table 4-5 Valid Values for cursor

Value Description

true


false

(Default)



Usage

A Cursor is a stream of the JDBC ResultSet. Cursors are useful for large results sets, or when you only need the few results of a query.

A cursor implements Enumeration, when the each next() will fetch the next from the JDBC ResultSet, and builds the resulting Object or value. A Cursor requires, and will keep, a live JDBC connection. You must use close() to free the Cursor's resources.

You can access a Cursor from a JPA Query through getSingleResult(), or from JpaQuery using getResultCursor().


Tip:

You can use MAX_ROWS and FIRST_RESULT instead of a Cursor to obtain a page of results.



Examples

Example 4-11 shows how to use this hint in a JPA query.

Example 4-11 Using cursor in a JPA Query

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint("eclipselink.cursor", "TRUE");

Example 4-12 shows how to use this hint with the @QueryHint annotation.

Example 4-12 Using cursor in a @QueryHint Annotation

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 @QueryHint(name=QueryHints.CURSOR, value="TRUE");


See Also

For more information, see: