mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix for Issue 35 Connection pool leak with findFutureRowCount(),
findFutureList() and findFutureIds()
This commit is contained in:
@@ -2,29 +2,36 @@ package com.avaje.ebeaninternal.server.query;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
|
||||
/**
|
||||
* Represent the findRowCount query as a Callable.
|
||||
*
|
||||
* @param <T> the entity bean type
|
||||
*
|
||||
* @param <T>
|
||||
* the entity bean type
|
||||
*/
|
||||
public class CallableQueryRowCount<T> extends CallableQuery<T> implements Callable<Integer> {
|
||||
|
||||
|
||||
public CallableQueryRowCount(SpiEbeanServer server, Query<T> query, Transaction t) {
|
||||
super(server, query, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the query returning the row count.
|
||||
*/
|
||||
public Integer call() throws Exception {
|
||||
return server.findRowCountWithCopy(query, t);
|
||||
}
|
||||
/**
|
||||
* Note that the transaction passed in is always a new transaction solely to
|
||||
* find the row count so it must be cleaned up by this CallableQueryRowCount.
|
||||
*/
|
||||
public CallableQueryRowCount(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
super(server, query, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the query returning the row count.
|
||||
*/
|
||||
public Integer call() throws Exception {
|
||||
try {
|
||||
return server.findRowCountWithCopy(query, transaction);
|
||||
} finally {
|
||||
// cleanup the underlying connection
|
||||
transaction.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user