Package org.apache.cayenne
Interface QueryResponse
- All Known Implementing Classes:
- GenericResponse,- IncrementalListResponse,- ListResponse
public interface QueryResponse
Represents a result of query execution. It potentially contain a mix of update counts
 and lists of selected values. Provides API somewhat similar to java.util.Iterator or
 java.sql.ResultSet for scanning through the individual results.
 
An example of iterating through a response:
 QueryResponse response = context.performGenericQuery(query);
 for (response.reset(); response.next();) {
     if (response.isList()) {
         List list = response.currentList();
         // ...
     }
     else {
         int[] updateCounts = response.currentUpdateCount();
         // ...
     }
 }
 
 
 In case the structure of the result is known, and only a single list or an update count is expected, there is a simpler API to access them:
QueryResponse response = context.performGenericQuery(query); List list = response.firstList(); int[] count = response.firstUpdateCount();
- Since:
- 1.2
- 
Method SummaryModifier and TypeMethodDescriptiondefault ResultIterator<?>Returns a current iterator.default List<?>Returns a List under the current iterator position.default int[]Returns an update count under the current iterator position.default ResultIterator<?>A utility method for quickly retrieving the Iterator in the response.default List<?>A utility method for quickly retrieving the first list in the response.default int[]A utility method for quickly retrieving the first update count from the response.default booleanReturns whether current response is an iteratordefault booleanisList()Returns whether current iteration result is a list or an update count.booleannext()Rewinds response iterator to the next result, returning true if it is available.voidreset()Restarts response iterator.intsize()Returns a number of results in the response.
- 
Method Details- 
sizeint size()Returns a number of results in the response.
- 
isListdefault boolean isList()Returns whether current iteration result is a list or an update count.
- 
isIteratordefault boolean isIterator()Returns whether current response is an iterator- Since:
- 5.0
 
- 
currentListReturns a List under the current iterator position. UseisList()to check the result type before calling this method.
- 
currentIteratorReturns a current iterator.- Since:
- 5.0
 
- 
currentUpdateCountdefault int[] currentUpdateCount()Returns an update count under the current iterator position. Returned value is an int[] to accommodate batch queries. For a regular update result, the value will be an int[1]. UseisList()to check the result type before calling this method.
- 
nextboolean next()Rewinds response iterator to the next result, returning true if it is available.
- 
resetvoid reset()Restarts response iterator.
- 
firstListA utility method for quickly retrieving the first list in the response. Returns null if the query has no lists. Note that this method resets current iterator to an undefined state.
- 
firstIteratorA utility method for quickly retrieving the Iterator in the response. Returns null if the query has no iterator.- Since:
- 5.0
 
- 
firstUpdateCountdefault int[] firstUpdateCount()A utility method for quickly retrieving the first update count from the response. Note that this method resets current iterator to an undefined state.
 
-