Class ScrollableQueryResult<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.datanucleus.store.query.AbstractQueryResult<E>
-
- org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult<E>
-
- org.datanucleus.store.rdbms.query.ScrollableQueryResult<E>
-
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,List<E>
,org.datanucleus.store.query.QueryResult<E>
public final class ScrollableQueryResult<E> extends AbstractRDBMSQueryResult<E> implements Serializable
Lazy collection results from a Query with the ResultSet scrollable. Supports the following query extensions (in addition to those supported by superclasses) :-- datanucleus.query.resultCacheType Type of caching of result objects. Supports strong, weak, soft, none
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Integer,Object>
resultIdsByPosition
Map of persistable object id, keyed by the result position (0, 1, 2, ...).-
Fields inherited from class org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
bulkLoadedValueByMemberNumber, closeStatementWithResultSet, fp, rof, rs
-
Fields inherited from class org.datanucleus.store.query.AbstractQueryResult
api, closed, connectionListeners, loadResultsAtCommit, query, resultSizeMethod, size
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description ScrollableQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection candidates)
Constructor of the result from a Query.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cacheQueryResults()
void
close()
Method to close the results, making the results unusable thereafter.protected void
closingConnection()
Inform the query result that the connection is being closed so perform any operations now, or rest in peace.boolean
equals(Object o)
E
get(int index)
Method to retrieve a particular element from the list.protected E
getObjectForIndex(int index)
Accessor for the result object at an index.protected int
getSizeUsingMethod()
Method to get the size using the "resultSizeMethod".int
hashCode()
void
initialise()
Iterator<E>
iterator()
Accessor for an iterator for the results.ListIterator<E>
listIterator()
Accessor for an iterator for the results.protected void
loadObjects(int start, int maxNumber)
Convenience method to load up rows starting at the specified position.Object[]
toArray()
Object[]
toArray(Object[] a)
protected Object
writeReplace()
Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.-
Methods inherited from class org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult
closeResults, disconnect, registerMemberBulkResultSet, setCloseStatementWithResultSet
-
Methods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, contains, containsAll, indexOf, isEmpty, isOpen, lastIndexOf, remove, set, size, subList
-
Methods inherited from class java.util.AbstractList
listIterator, removeRange
-
Methods inherited from class java.util.AbstractCollection
addAll, remove, removeAll, retainAll, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, remove, removeAll, replaceAll, retainAll, sort, spliterator
-
-
-
-
Constructor Detail
-
ScrollableQueryResult
public ScrollableQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection candidates)
Constructor of the result from a Query.- Parameters:
query
- The Queryrof
- The factory to retrieve results fromrs
- The ResultSet from the Query Statementfp
- FetchPlancandidates
- the Candidates collection. Pass this argument only when distinct = false
-
-
Method Detail
-
initialise
public void initialise()
- Specified by:
initialise
in classAbstractRDBMSQueryResult<E>
-
loadObjects
protected void loadObjects(int start, int maxNumber)
Convenience method to load up rows starting at the specified position. Optionally takes a maximum number of rows to process.- Parameters:
start
- Start rowmaxNumber
- Max number to process (-1 means no maximum)
-
getObjectForIndex
protected E getObjectForIndex(int index)
Accessor for the result object at an index. If the object has already been processed will return that object, otherwise will retrieve the object using the factory.- Parameters:
index
- The list index position- Returns:
- The result object
-
close
public void close()
Method to close the results, making the results unusable thereafter.- Specified by:
close
in interfaceorg.datanucleus.store.query.QueryResult<E>
- Overrides:
close
in classAbstractRDBMSQueryResult<E>
-
closingConnection
protected void closingConnection()
Inform the query result that the connection is being closed so perform any operations now, or rest in peace.- Specified by:
closingConnection
in classorg.datanucleus.store.query.AbstractQueryResult<E>
-
cacheQueryResults
protected void cacheQueryResults()
-
listIterator
public ListIterator<E> listIterator()
Accessor for an iterator for the results.- Specified by:
listIterator
in interfaceList<E>
- Specified by:
listIterator
in classorg.datanucleus.store.query.AbstractQueryResult<E>
- Returns:
- The iterator
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceList<E>
- Overrides:
equals
in classAbstractRDBMSQueryResult<E>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceList<E>
- Overrides:
hashCode
in classAbstractRDBMSQueryResult<E>
-
get
public E get(int index)
Method to retrieve a particular element from the list.
-
getSizeUsingMethod
protected int getSizeUsingMethod()
Method to get the size using the "resultSizeMethod". This implementation supports "LAST" method. Override this in subclasses to implement other methods.- Overrides:
getSizeUsingMethod
in classorg.datanucleus.store.query.AbstractQueryResult<E>
- Returns:
- The size
-
toArray
public Object[] toArray()
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.- Returns:
- The object to serialise
- Throws:
ObjectStreamException
- thrown if an error occurs
-
-