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

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

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

All Implemented Interfaces:
  ResultIterator

    public class JDBCResultIterator

extends java.lang.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 java.sql.Connection` | `connection`
`protected int` | `fetchedSoFar`
`protected int` | `fetchLimit`
`protected int` | `mapCapacity`
`protected boolean` | `nextRow`
`protected int[]` | `pkIndices`
`protected java.sql.ResultSet` | `resultSet`
`protected DbEntity` | `rootEntity`
`protected RowDescriptor` | `rowDescriptor`
`protected java.sql.Statement` | `statement`

Constructor Summary
`JDBCResultIterator(java.sql.Connection connection, java.sql.Statement statement, java.sql.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.
`java.util.List` | `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.
`java.util.Map` | `nextDataRow()` Returns the next result row as a Map.
`java.util.Map` | `nextObjectId(DbEntity entity)` Returns a map of ObjectId values from the next result row.
`protected java.util.Map` | `readDataRow()` Reads a row from the internal ResultSet at the current cursor position.
`protected java.util.Map` | `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 java.sql.Connection connection

### statement

    protected java.sql.Statement statement

### resultSet

    protected java.sql.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(java.sql.Connection connection,
                              java.sql.Statement statement,
                              java.sql.ResultSet resultSet,
                              RowDescriptor descriptor,
                              int fetchLimit)
                       throws CayenneException

  Creates new JDBCResultIterator that reads from provided ResultSet.

  Throws:
    `CayenneException`

Method Detail

### dataRows

    public java.util.List 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 java.util.Map nextDataRow()
                              throws CayenneException

  Returns the next result row as a Map.

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

### nextObjectId

    public java.util.Map 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`

### 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 java.util.Map readDataRow()
                                 throws CayenneException

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

  Throws:
    `CayenneException`

### readIdRow

    protected java.util.Map 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 | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 ObjectStyle.org All Rights Reserved.