com.j256.ormlite.stmt
Class SelectIterator<T,ID>

java.lang.Object
  extended by com.j256.ormlite.stmt.SelectIterator<T,ID>
All Implemented Interfaces:
CloseableIterator<T>, Iterator<T>

public class SelectIterator<T,ID>
extends Object
implements CloseableIterator<T>

Internal iterator so we can page through the class. This is used by the Dao.iterator() methods.

Author:
graywatson

Constructor Summary
SelectIterator(Class<?> dataClass, Dao<T,ID> classDao, GenericRowMapper<T> rowMapper, ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt, String statement, ObjectCache objectCache)
          If the statement parameter is null then this won't log information
 
Method Summary
 void close()
          Close any underlying SQL statements.
 DatabaseResults getRawResults()
          Return the underlying database results object if any.
 boolean hasNext()
          Returns whether or not there are any remaining objects in the table.
 boolean hasNextThrow()
          Returns whether or not there are any remaining objects in the table.
 void moveToNext()
          Move to the next item in the iterator without calling Iterator.next().
 T next()
          Returns the next() object in the table.
 T nextThrow()
          Returns the next() object in the table.
 void remove()
          Removes the last object returned by next() by calling delete on the dao associated with the object.
 void removeThrow()
          Removes the last object returned by next() by calling delete on the dao associated with the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectIterator

public SelectIterator(Class<?> dataClass,
                      Dao<T,ID> classDao,
                      GenericRowMapper<T> rowMapper,
                      ConnectionSource connectionSource,
                      DatabaseConnection connection,
                      CompiledStatement compiledStmt,
                      String statement,
                      ObjectCache objectCache)
               throws SQLException
If the statement parameter is null then this won't log information

Throws:
SQLException
Method Detail

hasNextThrow

public boolean hasNextThrow()
                     throws SQLException
Returns whether or not there are any remaining objects in the table. Must be called before next().

Throws:
SQLException - If there was a problem getting more results via SQL.

hasNext

public boolean hasNext()
Returns whether or not there are any remaining objects in the table. Must be called before next().

Specified by:
hasNext in interface Iterator<T>
Throws:
IllegalStateException - If there was a problem getting more results via SQL.

nextThrow

public T nextThrow()
            throws SQLException
Returns the next() object in the table.

Throws:
SQLException - If there was a problem extracting the object from SQL.

next

public T next()
Returns the next() object in the table.

Specified by:
next in interface Iterator<T>
Throws:
IllegalStateException - If there was a problem extracting the object from SQL.

removeThrow

public void removeThrow()
                 throws SQLException
Removes the last object returned by next() by calling delete on the dao associated with the object.

Throws:
IllegalStateException - If there was no previous next() call.
SQLException - If the delete failed.

remove

public void remove()
Removes the last object returned by next() by calling delete on the dao associated with the object.

Specified by:
remove in interface Iterator<T>
Throws:
IllegalStateException - If there was no previous next() call or if delete() throws a SQLException (set as the cause).

close

public void close()
           throws SQLException
Description copied from interface: CloseableIterator
Close any underlying SQL statements.

Specified by:
close in interface CloseableIterator<T>
Throws:
SQLException

getRawResults

public DatabaseResults getRawResults()
Description copied from interface: CloseableIterator
Return the underlying database results object if any. May return null. This should not be used unless you know what you are doing.

Specified by:
getRawResults in interface CloseableIterator<T>

moveToNext

public void moveToNext()
Description copied from interface: CloseableIterator
Move to the next item in the iterator without calling Iterator.next().

Specified by:
moveToNext in interface CloseableIterator<T>


This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.