Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.access.jdbc
Class JDBCResultIterator

    java.lang.Object
      org.apache.cayenne.access.jdbc.JDBCResultIterator

All Implemented Interfaces:
  ResultIterator

    public class JDBCResultIterator

extends Object
implements ResultIterator

A ResultIterator over the underlying JDBC ResultSet.

Since:
  1.2
Author:
  Andrus Adamchik

Field Summary
`protected boolean` | `closed`
`protected boolean` | `closingConnection`
`protected Connection` | `connection`
`protected int` | `fetchedSoFar`
`protected int` | `fetchLimit`
`protected int` | `mapCapacity`
`protected boolean` | `nextRow`
`protected int[]` | `pkIndices`
`protected ResultSet` | `resultSet`
`protected DbEntity` | `rootEntity`
`protected RowDescriptor` | `rowDescriptor`
`protected Statement` | `statement`

Constructor Summary
`JDBCResultIterator(Connection connection, Statement statement, ResultSet resultSet, RowDescriptor descriptor, int fetchLimit)` Creates new JDBCResultIterator that reads from provided ResultSet.

Method Summary
`protected void` | `checkNextRow()` Moves internal ResultSet cursor position down one row.
`void` | `close()` Closes ResultIterator and associated ResultSet.
`List<DataRow>` | `dataRows(boolean close)` Returns all unread data rows from ResultSet, closing this iterator if needed.
`int` | `getDataRowWidth()` Returns the number of columns in the result row.
`RowDescriptor` | `getRowDescriptor()`
`boolean` | `hasNextRow()` Returns true if there is at least one more record that can be read from the iterator.
`protected void` | `indexPK()` Creates an index of PK columns in the RowDescriptor.
`boolean` | `isClosingConnection()` Returns `true` if this iterator is responsible for closing its connection, otherwise a user of the iterator must close the connection after closing 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.
`protected Map<String,Object>` | `readDataRow()` Reads a row from the internal ResultSet at the current cursor position.
`protected Object` | `readId()`
`protected Map<String,Object>` | `readIdRow()` Reads a row from the internal ResultSet at the current cursor position, processing only columns that are part of the ObjectId of a target class.
`void` | `setClosingConnection(boolean flag)` Sets the `closingConnection` property.
`void` | `skipDataRow()` Skips current data row instead of reading it.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### connection

    protected Connection connection

### statement

    protected Statement statement

### resultSet

    protected ResultSet resultSet

### rowDescriptor

    protected RowDescriptor rowDescriptor

### rootEntity

    protected DbEntity rootEntity

### pkIndices

    protected int[] pkIndices

### mapCapacity

    protected int mapCapacity

### closingConnection

    protected boolean closingConnection

### closed

    protected boolean closed

### nextRow

    protected boolean nextRow

### fetchedSoFar

    protected int fetchedSoFar

### fetchLimit

    protected int fetchLimit

Constructor Detail

### JDBCResultIterator

    public JDBCResultIterator(Connection connection,
                              Statement statement,
                              ResultSet resultSet,
                              RowDescriptor descriptor,
                              int fetchLimit)
                       throws CayenneException

  Creates new JDBCResultIterator that reads from provided ResultSet.

  Throws:
    `CayenneException`

Method Detail

### dataRows

    public List<DataRow> dataRows(boolean close)
                           throws CayenneException

  Returns all unread data rows from ResultSet, closing this iterator if needed.

  Specified by:
    `dataRows` in interface `ResultIterator`
  Throws:
    `CayenneException`

### hasNextRow

    public boolean hasNextRow()

  Returns true if there is at least one more record that can be read from the iterator.

  Specified by:
    `hasNextRow` in interface `ResultIterator`

### nextDataRow

    public Map<String,Object> nextDataRow()
                                   throws CayenneException

  Returns the next result row as a Map.

  Specified by:
    `nextDataRow` in interface `ResultIterator`
  Throws:
    `CayenneException`

### nextObjectId

    public 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.

  Specified by:
    `nextObjectId` in interface `ResultIterator`
  Throws:
    `CayenneException`

### nextId

    public Object nextId(DbEntity entity)
                  throws CayenneException

  Description copied from interface: `ResultIterator`
  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 `ResultIterator.nextObjectId(DbEntity)`).

  Specified by:
    `nextId` in interface `ResultIterator`
  Throws:
    `CayenneException`
  Since:
    3.0

### skipDataRow

    public void skipDataRow()
                     throws CayenneException

  Description copied from interface: `ResultIterator`
  Skips current data row instead of reading it.

  Specified by:
    `skipDataRow` in interface `ResultIterator`
  Throws:
    `CayenneException`

### close

    public 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.

  Specified by:
    `close` in interface `ResultIterator`
  Throws:
    `CayenneException`

### getDataRowWidth

    public int getDataRowWidth()

  Returns the number of columns in the result row.

  Specified by:
    `getDataRowWidth` in interface `ResultIterator`

### checkNextRow

    protected void checkNextRow()
                         throws CayenneException

  Moves internal ResultSet cursor position down one row. Checks if the next row is available.

  Throws:
    `CayenneException`

### readDataRow

    protected Map<String,Object> readDataRow()
                                      throws CayenneException

  Reads a row from the internal ResultSet at the current cursor position.

  Throws:
    `CayenneException`

### readId

    protected Object readId()
                     throws CayenneException

  Throws:
    `CayenneException`

### readIdRow

    protected Map<String,Object> readIdRow()
                                    throws CayenneException

  Reads a row from the internal ResultSet at the current cursor position, processing only columns that are part of the ObjectId of a target class.

  Throws:
    `CayenneException`

### indexPK

    protected void indexPK()

  Creates an index of PK columns in the RowDescriptor.

### isClosingConnection

    public boolean isClosingConnection()

  Returns `true` if this iterator is responsible for closing its connection, otherwise a user of the iterator must close the connection after closing the iterator.

### setClosingConnection

    public void setClosingConnection(boolean flag)

  Sets the `closingConnection` property.

### getRowDescriptor

    public RowDescriptor getRowDescriptor()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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