org.apache.cayenne.access
Interface ResultIterator

All Known Implementing Classes:
DistinctResultIterator, JDBCResultIterator, LimitResultIterator

public interface ResultIterator

Defines API of an iterator over the records returned as a result of SelectQuery execution. Usually a ResultIterator is supported by an open java.sql.ResultSet, therefore most of the methods would throw checked exceptions. ResultIterators must be explicitly closed when the user is done working with them.


Method Summary
 void close()
          Closes ResultIterator and associated ResultSet.
 List<DataRow> dataRows(boolean close)
          Returns all unread data rows from ResultSet and closes this iterator if asked to do so.
 int getDataRowWidth()
          Returns the number of columns in the result row.
 boolean hasNextRow()
          Returns true if there is at least one more record that can be read from the iterator.
 Map<String,Object> nextDataRow()
          Returns the next result row as a Map.
 Object nextId(DbEntity entity)
          Reads and returns an id column or columns for the DbEntity.
 Map<String,Object> nextObjectId(DbEntity entity)
          Returns a map of ObjectId values from the next result row.
 void skipDataRow()
          Skips current data row instead of reading it.
 

Method Detail

dataRows

List<DataRow> dataRows(boolean close)
                       throws CayenneException
Returns all unread data rows from ResultSet and closes this iterator if asked to do so.

Throws:
CayenneException

hasNextRow

boolean hasNextRow()
                   throws CayenneException
Returns true if there is at least one more record that can be read from the iterator.

Throws:
CayenneException

nextDataRow

Map<String,Object> nextDataRow()
                               throws CayenneException
Returns the next result row as a Map.

Throws:
CayenneException

nextObjectId

Map<String,Object> nextObjectId(DbEntity entity)
                                throws CayenneException
Returns a map of ObjectId values from the next result row. Primary key columns are determined from the provided DbEntity.

Throws:
CayenneException
Since:
1.1

nextId

Object nextId(DbEntity entity)
              throws CayenneException
Reads and returns an id column or columns for the DbEntity. If an entity has a single column id, the return value is an Object matching the column type (e.g. java.lang.Long). If an entity has a compound PK, the return value is a DataRow (i.e. equivalent to nextObjectId(DbEntity)).

Throws:
CayenneException
Since:
3.0

skipDataRow

void skipDataRow()
                 throws CayenneException
Skips current data row instead of reading it.

Throws:
CayenneException

close

void close()
           throws CayenneException
Closes ResultIterator and associated ResultSet. This method must be called explicitly when the user is finished processing the records. Otherwise unused database resources will not be released properly.

Throws:
CayenneException

getDataRowWidth

int getDataRowWidth()
Returns the number of columns in the result row.

Since:
1.0.6


Copyright © 2001-2008 Apache Cayenne. All Rights Reserved.