Add cancel() support to the Query and SqlQuery.
There is now a cancel() method on these query objects but possibly more often you will use the "future" queries that return a future object - and call query on that.
An example executing a query using a background thread... and cancelling it if it didn't finish after 3 seconds.
NB: the future.cancel(timeout) can also be used.
Query<Order> query = Ebean.find(Order.class); // execute the query using a background thread and // return immediately with a FutureList object FutureList<Order> futureList = query.findFutureList(); // do something else ... but we will just sleep Thread.sleep(3000); System.out.println("end of sleep"); if (!futureList.isDone()){ // cancel the query futureList.cancel(true); }
This code to support query.cancel() is now in head.