Class ForwardQueryResult<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.ForwardQueryResult<E>
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, org.datanucleus.store.query.QueryResult<E>
public final class ForwardQueryResult<E>
extends AbstractRDBMSQueryResult<E>
implements Serializable
Lazy collection results from a Query with the ResultSet in a forward direction.
In general the actual result elements are only loaded when accessed with the exception of
non-transactional or optimistic contexts that load the elements at initialisation.
If the query had a range defined and this was not handled in the datastore query then this QueryResult will skip the unrequired records and just return the range requested.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classAn Iterator results of a pm.query.execute().iterator() -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Collection<Object> The candidate list restriction (optional).protected booleanWhether there are still more rows to be processed in the ResultSet.The Result Objects.Fields inherited from class AbstractRDBMSQueryResult
applyRangeChecks, bulkLoadedMmds, bulkLoadedValueByMemberNumber, closeStatementWithResultSet, fp, rof, rsFields inherited from class org.datanucleus.store.query.AbstractQueryResult
api, closed, connectionListeners, loadResultsAtCommit, query, resultSizeMethod, sizeFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionForwardQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection<Object> candidates) Constructor of the result from a Query. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidInternal method to advance to the end of the ResultSet, populating the resultObjs, and close the ResultSet when complete.voidclose()Method to close the results, making the results unusable thereafter.protected voidInternal method to close the ResultSet.protected voidMethod called to inform the query result that the connection is being closed so perform any required operations now, or rest in peace.booleanMethod to check if the specified object is contained in this result.booleanMethod to check if all of the specified objects are contained here.booleanget(int index) Method to retrieve a particular element from the list.protected intMethod to get the size using the "resultSizeMethod".inthashCode()voidbooleanisEmpty()Accessor for whether there are any results.iterator()Accessor for an iterator for the results.Accessor for an iterator for the results.protected EAccessor for the next object from the ResultSet.private voidprocessNumberOfResults(int number) Method to advance through the results, processing the specified number of results.Object[]toArray()Method to return the results as an array.<T> T[]toArray(T[] a) Method to return the results as an array.protected ObjectHandle 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 AbstractRDBMSQueryResult
disconnect, registerMemberBulkResultSet, setCloseStatementWithResultSetMethods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, indexOf, isOpen, lastIndexOf, remove, set, size, subListMethods inherited from class AbstractList
listIterator, removeRangeMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addAll, addFirst, addLast, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator
-
Field Details
-
moreResultSetRows
protected boolean moreResultSetRowsWhether there are still more rows to be processed in the ResultSet. -
resultObjs
-
resultIds
-
candidates
The candidate list restriction (optional).
-
-
Constructor Details
-
ForwardQueryResult
public ForwardQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection<Object> 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- Candidate elements
-
-
Method Details
-
initialise
- Specified by:
initialisein classAbstractRDBMSQueryResult<E>- Throws:
SQLException
-
processNumberOfResults
private void processNumberOfResults(int number) Method to advance through the results, processing the specified number of results.- Parameters:
number- Number of results (-1 means process all)
-
advanceToEndOfResultSet
private void advanceToEndOfResultSet()Internal method to advance to the end of the ResultSet, populating the resultObjs, and close the ResultSet when complete. -
nextResultSetElement
Accessor for the next object from the ResultSet.- Returns:
- The next element from the ResultSet.
-
closeResults
protected void closeResults()Internal method to close the ResultSet.- Overrides:
closeResultsin classAbstractRDBMSQueryResult<E>
-
close
public void close()Method to close the results, making the results unusable thereafter.- Specified by:
closein interfaceorg.datanucleus.store.query.QueryResult<E>- Overrides:
closein classAbstractRDBMSQueryResult<E>
-
closingConnection
protected void closingConnection()Method called to inform the query result that the connection is being closed so perform any required operations now, or rest in peace.- Specified by:
closingConnectionin classorg.datanucleus.store.query.AbstractQueryResult<E>
-
iterator
Accessor for an iterator for the results. -
listIterator
Accessor for an iterator for the results.- Specified by:
listIteratorin interfaceList<E>- Specified by:
listIteratorin classorg.datanucleus.store.query.AbstractQueryResult<E>- Returns:
- The iterator
-
contains
Method to check if the specified object is contained in this result. -
containsAll
Method to check if all of the specified objects are contained here.- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- Overrides:
containsAllin classorg.datanucleus.store.query.AbstractQueryResult<E>- Parameters:
c- The collection of objects- Returns:
- Whether they are all contained here.
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classAbstractRDBMSQueryResult<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classAbstractRDBMSQueryResult<E>
-
get
-
isEmpty
-
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:
getSizeUsingMethodin classorg.datanucleus.store.query.AbstractQueryResult<E>- Returns:
- The size
-
toArray
-
toArray
public <T> T[] toArray(T[] a) Method to return the results as an array. -
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.- Returns:
- The object to serialise
- Throws:
ObjectStreamException- Thrown if an error occurs
-