com.avaje.ebean
Interface FutureList<T>

All Superinterfaces:
Future<List<T>>

public interface FutureList<T>
extends Future<List<T>>

FutureList represents the result of a background query execution that will return a list of entities.

It extends the java.util.concurrent.Future with the ability to cancel the query, check if it is finished and get the resulting list waiting for the query to finish (ie. the standard features of java.util.concurrent.Future).

A simple example:

  // create a query to find all orders
 Query<Order> query = Ebean.find(Order.class);
 
  // execute the query in a background thread
  // immediately returning the futureList
 FutureList<Order> futureList = query.findFutureList();
 
  // do something else ... 
 
 if (!futureList.isDone()){
        // we can cancel the query execution. This will cancel
        // the underlying query if that is supported by the JDBC
        // driver and database
        futureList.cancel(true);
 }
 
 
 if (!futureList.isCancelled()){
        // wait for the query to finish and return the list
        List<Order> list = futureList.get();
        ...
 }
 
 

Author:
rbygrave

Method Summary
 Query<T> getQuery()
          Return the query that is being executed by a background thread.
 
Methods inherited from interface java.util.concurrent.Future
cancel, get, get, isCancelled, isDone
 

Method Detail

getQuery

Query<T> getQuery()
Return the query that is being executed by a background thread.



Copyright © 2010. All Rights Reserved.