
com.avaje.ebean.QueryResultVisitor Maven / Gradle / Ivy
The newest version!
package com.avaje.ebean;
/**
* Used to process a query result one bean at a time via a callback to this
* visitor.
*
* If you wish to stop further processing return false from the accept method.
*
*
* Unlike findList() and findSet() using a QueryResultVisitor does not require
* all the beans in the query result to be held in memory at once. This makes
* QueryResultVisitor useful for processing large queries.
*
*
*
*
* Query<Customer> query = server.find(Customer.class)
* .fetch("contacts", new FetchConfig().query(2))
* .where().gt("id", 0)
* .orderBy("id")
* .setMaxRows(2);
*
* query.findVisit(new QueryResultVisitor<Customer>() {
*
* public boolean accept(Customer customer) {
* // do something with customer
* System.out.println("-- visit " + customer);
* return true;
* }
* });
*
*
* @author rbygrave
*
* @param
* the type of entity bean being queried.
*/
public interface QueryResultVisitor {
/**
* Process the bean and return true if you want to continue processing more
* beans. Return false if you want to stop processing further.
*
* @param bean
* the entity bean to process
* @return true to continue processing or false to stop.
*/
public boolean accept(T bean);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy