de.esprit.appsuite.database.dbase

## Class RecordIterator<R extends DBObject>

- java.lang.Object
- - de.esprit.appsuite.database.dbase.RecordIterator<R>

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class RecordIterator<R extends DBObject>
      extends java.lang.Object
      implements java.io.Closeable

  This Iterator executes a select query on the given master instance and then iterates through the ResultSet. Note that the records are NOT loaded into memory all at once but are fetched in chunks while iterating through them.

  Note that the underlying ResultSet is closed automatically when all records have been read. But you MUST close the ResultSet by yourself if you break the iteration before reaching the end.

  Note that if no order clause is given, then default ordering by primary key is assumed. If you don't want ordering, then you should pass a null value as order clause.

  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RecordIterator(DBObject master)`
    `RecordIterator(DBObject master, SqlCondition condition)`
    `RecordIterator(DBObject master, SqlCondition condition, SqlOrder order)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the underlying ResultSet.
    `int` | `getRecordCount()` Returns the number of records that have been read during the iteration.
    `boolean` | `hasNext()` Checks the underlying ResultSet whether there are more records to read.
    `R` | `next()` Reads the next record from the underlying ResultSet.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RecordIterator

          public RecordIterator(DBObject master)
                         throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### RecordIterator

          public RecordIterator(DBObject master,
                        SqlCondition condition)
                         throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

    - #### RecordIterator

          public RecordIterator(DBObject master,
                        SqlCondition condition,
                        SqlOrder order)
                         throws java.sql.SQLException

      Throws:
        `java.sql.SQLException`

  - ### Method Detail

    - #### close

          public void close()

      Closes the underlying ResultSet. The ResultSet is closed automatically when all records have been read. But you MUST close the ResultSet by yourself if you break the iteration before reaching the end.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### hasNext

          public boolean hasNext()
                          throws java.sql.SQLException

      Checks the underlying ResultSet whether there are more records to read. The ResultSet is automatically closed when all records have been read.
      Throws:
        `java.sql.SQLException`
      See Also:
        `close()`

    - #### next

          public R next()
                                  throws java.sql.SQLException

      Reads the next record from the underlying ResultSet. Before calling this method you must have checked the availability of a record with the hasNext() method.
      Throws:
        `java.sql.SQLException`
      See Also:
        `hasNext()`

    - #### getRecordCount

          public int getRecordCount()

      Returns the number of records that have been read during the iteration.

Copyright © 2014 EsprIT-Systems. All Rights Reserved.