Use eclipselink.cursor
to configure the query to return a CursoredStream
.
Values
Table 4-5 describes this persistence property's values.
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 |
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: