mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
37 lines
938 B
Java
37 lines
938 B
Java
package io.ebeaninternal.server.query;
|
|
|
|
import io.ebean.Transaction;
|
|
import io.ebeaninternal.api.SpiEbeanServer;
|
|
import io.ebeaninternal.api.SpiQuery;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
/**
|
|
* Represent the findCount query as a Callable.
|
|
*
|
|
* @param <T> the entity bean type
|
|
*/
|
|
public class CallableQueryCount<T> extends CallableQuery<T> implements Callable<Integer> {
|
|
|
|
/**
|
|
* 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 CallableQueryCount(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.findCountWithCopy(query, transaction);
|
|
} finally {
|
|
// cleanup the underlying connection
|
|
transaction.end();
|
|
}
|
|
}
|
|
|
|
}
|