- java.lang.Object
-
- org.eclipse.persistence.queries.Cursor
-
- All Implemented Interfaces:
Serializable,Enumeration,Iterator
- Direct Known Subclasses:
CursoredStream,ScrollableCursor
public abstract class Cursor extends Object implements Enumeration, Iterator, Serializable
Purpose: Abstract class for CursoredStream and ScrolableCursor
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractSessionexecutionSessionThe root session that executed the call for the query.protected Vector<DatabaseField>fieldsThe fields expected in the result set.protected Map<Object,Object>initiallyConformingIndexConforming instances found in memory when building the result.protected AbstractRecordnextRowStore the next row, for 1-m joining.protected List<Object>objectCollectionInternal collection of objects.CursorPolicypolicyQuery policy that initialize the stream.protected intpositionCurrent position in the objectCollection of the stream.ReadQueryqueryRead query that initialize the stream.protected ResultSetresultSetThe result set (cursor) that holds the handle to the database that the results are read from.protected ExpressionselectionCriteriaCloneSelectionCriteria & translation row ready for incremental conforming.protected AbstractSessionsessionThe session that executed the query for the stream.protected intsizeCached size of the stream.protected StatementstatementThe preparedStatement that holds the handle to the database that the results are read from.protected AbstractRecordtranslationRow
-
Constructor Summary
Constructors Modifier Constructor Description protectedCursor()INTERNAL: Default constructor.protectedCursor(DatabaseCall call, CursorPolicy policy)INTERNAL:
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ObjectbuildAndRegisterObject(AbstractRecord row)INTERNAL: builds and registers an object from a row for cursors.voidclear()PUBLIC: Release all objects read in so far.voidclose()PUBLIC: Closes the stream.protected voidfinalize()Close in case not closed.DatabaseAccessorgetAccessor()INTERNAL: Return the accessor associated with the cursor.protected abstract intgetCursorSize()INTERNAL: Retrieve the size of the open cursor by executing a count on the same query as the cursor.AbstractSessiongetExecutionSession()INTERNAL: Returns the session the underlying call was executed on.Vector<DatabaseField>getFields()INTERNAL: Return the fields for the stream.Map<Object,Object>getInitiallyConformingIndex()INTERNAL: Conforming instances found in memory when building the result.List<Object>getObjectCollection()INTERNAL: Return the internal object collection that stores the objects.intgetPageSize()INTERNAL: Return the number of items to be faulted in for the stream.CursorPolicygetPolicy()INTERNAL: Return the cursor policy.abstract intgetPosition()INTERNAL: Return the position of the stream inside the object collection.ReadQuerygetQuery()INTERNAL: Return the query associated with the stream.ResultSetgetResultSet()INTERNAL: Return the result set (cursor).ExpressiongetSelectionCriteriaClone()INTERNAL: The clone of the selection criteria is needed for in-memory conforming each object read from the Cursor.AbstractSessiongetSession()INTERNAL: Return the handle to the sessionprotected StatementgetStatement()INTERNAL: Return the Statement.protected AbstractRecordgetTranslationRow()INTERNAL: Gets the translation row the query was executed with, used for incremental conforming.booleanisClosed()PUBLIC: Return if the stream is closed.voidremove()PUBLIC: Remove is not support with cursors.protected abstract ObjectretrieveNextObject()INTERNAL: Read the next row from the result set.protected voidsetExecutionSession(AbstractSession executionSession)INTERNAL: Sets the session the underlying call was executed on.protected voidsetFields(Vector<DatabaseField> fields)INTERNAL: Set the fields for the stream.voidsetInitiallyConformingIndex(Map<Object,Object> index)INTERNAL: Conforming instances found in memory when building the result.voidsetObjectCollection(List<Object> collection)INTERNAL: Set the internal object collectionvoidsetPolicy(CursorPolicy policy)INTERNAL: Set the cursor policy.protected voidsetPosition(int value)INTERNAL: Set the current position of the streamprotected voidsetResultSet(ResultSet result)INTERNAL: Set the result set (cursor)voidsetSelectionCriteriaClone(Expression expression)INTERNAL: The clone of the selection criteria is needed for in-memory conforming each object read from the Cursor.voidsetSession(AbstractSession databaseSession)INTERNAL: Set the session handlevoidsetSize(int size)INTERNAL: Set the cache sizevoidsetTranslationRow(AbstractRecord row)INTERNAL: Sets the translation row this query was executed with.intsize()PUBLIC: Retrieve the size of the open cursor by executing a count on the same query as the cursor.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Enumeration
asIterator, hasMoreElements, nextElement
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
-
-
-
Field Detail
-
statement
protected transient Statement statement
The preparedStatement that holds the handle to the database that the results are read from.
-
resultSet
protected transient ResultSet resultSet
The result set (cursor) that holds the handle to the database that the results are read from.
-
session
protected transient AbstractSession session
The session that executed the query for the stream.
-
executionSession
protected transient AbstractSession executionSession
The root session that executed the call for the query. Knows the database platform.
-
fields
protected transient Vector<DatabaseField> fields
The fields expected in the result set.
-
size
protected int size
Cached size of the stream.
-
query
public transient ReadQuery query
Read query that initialize the stream.
-
policy
public transient CursorPolicy policy
Query policy that initialize the stream.
-
initiallyConformingIndex
protected Map<Object,Object> initiallyConformingIndex
Conforming instances found in memory when building the result.
-
selectionCriteriaClone
protected Expression selectionCriteriaClone
SelectionCriteria & translation row ready for incremental conforming.
-
translationRow
protected AbstractRecord translationRow
-
nextRow
protected AbstractRecord nextRow
Store the next row, for 1-m joining.
-
position
protected int position
Current position in the objectCollection of the stream.
-
-
Constructor Detail
-
Cursor
protected Cursor()
INTERNAL: Default constructor.
-
Cursor
protected Cursor(DatabaseCall call, CursorPolicy policy)
INTERNAL:
-
-
Method Detail
-
close
public void close() throws DatabaseExceptionPUBLIC: Closes the stream. This should be performed whenever the user has finished with the stream.- Throws:
DatabaseException
-
finalize
protected void finalize() throws DatabaseExceptionClose in case not closed.- Overrides:
finalizein classObject- Throws:
DatabaseException
-
getAccessor
public DatabaseAccessor getAccessor()
INTERNAL: Return the accessor associated with the cursor.
-
getCursorSize
protected abstract int getCursorSize() throws DatabaseException, QueryExceptionINTERNAL: Retrieve the size of the open cursor by executing a count on the same query as the cursor.- Throws:
DatabaseExceptionQueryException
-
getFields
public Vector<DatabaseField> getFields()
INTERNAL: Return the fields for the stream.
-
getInitiallyConformingIndex
public Map<Object,Object> getInitiallyConformingIndex()
INTERNAL: Conforming instances found in memory when building the result. These objects are returned first by the cursor, and a fast lookup is needed to make sure the same objects appearing in the cursor are filtered out.
-
getObjectCollection
public List<Object> getObjectCollection()
INTERNAL: Return the internal object collection that stores the objects.
-
getPageSize
public int getPageSize()
INTERNAL: Return the number of items to be faulted in for the stream.
-
getPolicy
public CursorPolicy getPolicy()
INTERNAL: Return the cursor policy.
-
getPosition
public abstract int getPosition()
INTERNAL: Return the position of the stream inside the object collection.
-
getQuery
public ReadQuery getQuery()
INTERNAL: Return the query associated with the stream.
-
getResultSet
public ResultSet getResultSet()
INTERNAL: Return the result set (cursor).
-
getSelectionCriteriaClone
public Expression getSelectionCriteriaClone()
INTERNAL: The clone of the selection criteria is needed for in-memory conforming each object read from the Cursor.
-
getSession
public AbstractSession getSession()
INTERNAL: Return the handle to the session
-
getExecutionSession
public AbstractSession getExecutionSession()
INTERNAL: Returns the session the underlying call was executed on. This root session knows the database platform.
-
getStatement
protected Statement getStatement()
INTERNAL: Return the Statement.
-
getTranslationRow
protected AbstractRecord getTranslationRow()
INTERNAL: Gets the translation row the query was executed with, used for incremental conforming.
-
isClosed
public boolean isClosed()
PUBLIC: Return if the stream is closed.
-
buildAndRegisterObject
protected Object buildAndRegisterObject(AbstractRecord row)
INTERNAL: builds and registers an object from a row for cursors. Behavior is different from the query version in that refreshing is not supported.
-
retrieveNextObject
protected abstract Object retrieveNextObject() throws DatabaseException
INTERNAL: Read the next row from the result set.- Throws:
DatabaseException
-
setFields
protected void setFields(Vector<DatabaseField> fields)
INTERNAL: Set the fields for the stream.
-
setInitiallyConformingIndex
public void setInitiallyConformingIndex(Map<Object,Object> index)
INTERNAL: Conforming instances found in memory when building the result. These objects are returned first by the cursor, and a fast lookup is needed to make sure the same objects appearing in the cursor are filtered out.
-
setObjectCollection
public void setObjectCollection(List<Object> collection)
INTERNAL: Set the internal object collection
-
setPolicy
public void setPolicy(CursorPolicy policy)
INTERNAL: Set the cursor policy.
-
setPosition
protected void setPosition(int value)
INTERNAL: Set the current position of the stream
-
setResultSet
protected void setResultSet(ResultSet result)
INTERNAL: Set the result set (cursor)
-
setSelectionCriteriaClone
public void setSelectionCriteriaClone(Expression expression)
INTERNAL: The clone of the selection criteria is needed for in-memory conforming each object read from the Cursor.
-
setSession
public void setSession(AbstractSession databaseSession)
INTERNAL: Set the session handle
-
setExecutionSession
protected void setExecutionSession(AbstractSession executionSession)
INTERNAL: Sets the session the underlying call was executed on. This root session knows the database platform.
-
setSize
public void setSize(int size)
INTERNAL: Set the cache size
-
setTranslationRow
public void setTranslationRow(AbstractRecord row)
INTERNAL: Sets the translation row this query was executed with. Used for incremental conforming.
-
size
public int size() throws DatabaseExceptionPUBLIC: Retrieve the size of the open cursor by executing a count on the same query as the cursor. If this cursor is conforming size() can only be an estimate. cursor size plus number of conforming instances found in memory will be returned. The union (actual result) may be smaller than this.- Throws:
DatabaseException
-
remove
public void remove() throws QueryExceptionPUBLIC: Remove is not support with cursors.- Specified by:
removein interfaceIterator- Throws:
QueryException
-
clear
public void clear()
PUBLIC: Release all objects read in so far. This should be performed when reading in a large collection of objects in order to preserve memory.
-
-