Add support for executing some of the query types using a background thread returning Future objects. These are supported on Query, Ebean and EbeanServer.
public Future findFutureRowCount();
public FutureIds findFutureIds();
public FutureList findFutureList();
Query<Order> query = Ebean.find(Order.class); FutureList<Order> futureList = query.findFutureList(); Thread.sleep(3000); System.out.println("end of sleep"); if (!futureList.isDone()){ futureList.cancel(true); } System.out.println("and... done:"+futureList.isDone()); if (!futureList.isCancelled()){ List<Order> list = futureList.get(); System.out.println("list:"+list); }
// this will execute the query asynchronously in a background thread // immediately returning a Future object ... which you can use to // cancel() isDone() or get() with or without a timeout FutureList<Order> futureList = query.findFutureList();
This code is in HEAD.