com.avaje.ebean
Interface QueryIterator<T>

Type Parameters:
T - the type of entity bean in the iteration
All Superinterfaces:
Closeable, Iterator<T>

public interface QueryIterator<T>
extends Iterator<T>, Closeable

Used to provide iteration over query results.

This can be used when you want to process a very large number of results and means that you don't have to hold all the results in memory at once (unlike findList(), findSet() etc where all the beans are held in the List or Set etc).

 
 Query<Customer> query = server.find(Customer.class)
  .fetch("contacts", new FetchConfig().query(2))
  .where().gt("id", 0)
  .orderBy("id")
  .setMaxRows(2);
 
 QueryIterator<Customer> it = query.findIterate();
 try {
     while (it.hasNext()) {
         Customer customer = it.next();
         // do something with customer... 
     }
 } finally {
     // close the associated resources
     it.close();
 }
 

Author:
rbygrave

Method Summary
 void close()
          Close the underlying resources held by this iterator.
 boolean hasNext()
          Returns true if the iteration has more elements.
 T next()
          Returns the next element in the iteration.
 void remove()
          Remove is not allowed.
 

Method Detail

hasNext

boolean hasNext()
Returns true if the iteration has more elements.

Specified by:
hasNext in interface Iterator<T>

next

T next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator<T>

remove

void remove()
Remove is not allowed.

Specified by:
remove in interface Iterator<T>

close

void close()
Close the underlying resources held by this iterator.

Specified by:
close in interface Closeable


Copyright © 2012. All Rights Reserved.