Class CandidateIdsQueryResult<E>

All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, QueryResult<E>

public class CandidateIdsQueryResult<E> extends AbstractQueryResult<E>
QueryResult taking in the list of identities of the objects of candidate type. This is used where we cached the results of a query (the "ids") and just want to materialise them. User can define the query extension "datanucleus.query.resultCache.type" to define the type of internal caching of objects once they are found. User can also define whether the returned objects are validated against the datastore upon retrieval using the query extension "datanucleus.query.resultCache.validateObjects" (default=true).
See Also:
  • Field Details

    • ids

      final List<Object> ids
      List of identities of the candidate objects.
    • results

      Map<Integer,E> results
    • validateObjects

      boolean validateObjects
      Whether to validate the objects if getting from the cache.
  • Constructor Details

    • CandidateIdsQueryResult

      public CandidateIdsQueryResult(Query query, List<Object> inputIds)
  • Method Details

    • closeResults

      protected void closeResults()
      Description copied from class: AbstractQueryResult
      Inform the query result that we are closing the results now.
      Specified by:
      closeResults in class AbstractQueryResult<E>
    • closingConnection

      protected void closingConnection()
      Description copied from class: AbstractQueryResult
      Inform the query result that the connection is being closed so perform any operations now, or rest in peace.
      Specified by:
      closingConnection in class AbstractQueryResult<E>
    • equals

      public boolean equals(Object o)
      Description copied from class: AbstractQueryResult
      Equality operator for QueryResults. Overrides the AbstractList implementation since that uses size() and iterator() and that would cause problems when closed.
      Specified by:
      equals in interface Collection<E>
      Specified by:
      equals in interface List<E>
      Specified by:
      equals in class AbstractQueryResult<E>
      Parameters:
      o - The object to compare against
      Returns:
      Whether they are equal
    • hashCode

      public int hashCode()
      Description copied from class: AbstractQueryResult
      Accessor for the hashcode of this object
      Specified by:
      hashCode in interface Collection<E>
      Specified by:
      hashCode in interface List<E>
      Overrides:
      hashCode in class AbstractQueryResult<E>
      Returns:
      The hash code
    • get

      public E get(int index)
      Description copied from class: AbstractQueryResult
      Method to retrieve a particular element from the list.
      Specified by:
      get in interface List<E>
      Specified by:
      get in class AbstractQueryResult<E>
      Parameters:
      index - The index of the element
      Returns:
      The element at index
    • iterator

      public Iterator<E> iterator()
      Description copied from class: AbstractQueryResult
      Accessor for an iterator for the results.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface List<E>
      Specified by:
      iterator in class AbstractQueryResult<E>
      Returns:
      The iterator
    • listIterator

      public ListIterator<E> listIterator()
      Description copied from class: AbstractQueryResult
      Accessor for a list iterator for the results.
      Specified by:
      listIterator in interface List<E>
      Specified by:
      listIterator in class AbstractQueryResult<E>
      Returns:
      a ListIterator with the query results
    • getObjectForIndex

      protected E getObjectForIndex(int index)
      Convenience method to get the object for a particular index. Loads the object as required, or takes it from the internal cache (if present). Stores the returned object in the internal cache (if present).
      Parameters:
      index - The index
      Returns:
      The object
    • 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 - if an error occurs