Bug 141 : ENHANCEMENT: Add support for executing queries fully in the background with the ability to cancel the query
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.1.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
18/08/2009
Updated 
18/08/2009
Type 
Bug
 
Attachments 
No attachments

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();

 
Rob 19 Aug 11:42
Example
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);
}

Rob 19 Aug 11:44
...
// 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();

Rob 19 Aug 21:40
This is in HEAD

This code is in HEAD.

woResponse

Upload a file