mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#921 - Refactor internals - Change internal use of "findRowCount" to "findCount"
This commit is contained in:
@@ -121,8 +121,8 @@ public class ManyWhereJoins implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* In findRowCount query found a formula property with a join clause so building a select clause
|
||||
* specifically for the findRowCount query.
|
||||
* In findCount query found a formula property with a join clause so building a select clause
|
||||
* specifically for the findCount query.
|
||||
*/
|
||||
public void addFormulaWithJoin(String propertyName) {
|
||||
if (formulaWithJoin) {
|
||||
@@ -142,7 +142,7 @@ public class ManyWhereJoins implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the formula properties to build the select clause for a findRowCount query.
|
||||
* Return the formula properties to build the select clause for a findCount query.
|
||||
*/
|
||||
public String getFormulaProperties() {
|
||||
return formulaProperties.toString();
|
||||
|
||||
@@ -155,9 +155,9 @@ public interface SpiEbeanServer extends EbeanServer, BeanLoader, BeanCollectionL
|
||||
<A, T> List<A> findIdsWithCopy(Query<T> query, Transaction t);
|
||||
|
||||
/**
|
||||
* Execute the findRowCount query but without copying the query.
|
||||
* Execute the findCount query but without copying the query.
|
||||
*/
|
||||
<T> int findRowCountWithCopy(Query<T> query, Transaction t);
|
||||
<T> int findCountWithCopy(Query<T> query, Transaction t);
|
||||
|
||||
/**
|
||||
* Load a batch of Associated One Beans.
|
||||
|
||||
@@ -86,7 +86,7 @@ public interface SpiQuery<T> extends Query<T> {
|
||||
/**
|
||||
* Find rowCount.
|
||||
*/
|
||||
ROWCOUNT,
|
||||
COUNT,
|
||||
|
||||
/**
|
||||
* A subquery used as part of a where clause.
|
||||
|
||||
@@ -136,7 +136,7 @@ public class BaseQueryTuner {
|
||||
private boolean tunableQuery(SpiQuery<?> query) {
|
||||
SpiQuery.Type type = query.getType();
|
||||
switch (type) {
|
||||
case ROWCOUNT:
|
||||
case COUNT:
|
||||
case ID_LIST:
|
||||
case DELETE:
|
||||
case SUBQUERY:
|
||||
|
||||
@@ -73,7 +73,7 @@ import io.ebeaninternal.server.query.CQuery;
|
||||
import io.ebeaninternal.server.query.CQueryEngine;
|
||||
import io.ebeaninternal.server.query.CallableQueryIds;
|
||||
import io.ebeaninternal.server.query.CallableQueryList;
|
||||
import io.ebeaninternal.server.query.CallableQueryRowCount;
|
||||
import io.ebeaninternal.server.query.CallableQueryCount;
|
||||
import io.ebeaninternal.server.query.LimitOffsetPagedList;
|
||||
import io.ebeaninternal.server.query.QueryFutureIds;
|
||||
import io.ebeaninternal.server.query.QueryFutureList;
|
||||
@@ -1216,19 +1216,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
public <T> int findCount(Query<T> query, Transaction t) {
|
||||
|
||||
SpiQuery<T> copy = ((SpiQuery<T>) query).copy();
|
||||
return findRowCountWithCopy(copy, t);
|
||||
return findCountWithCopy(copy, t);
|
||||
}
|
||||
|
||||
public <T> int findRowCount(Query<T> query, Transaction t) {
|
||||
return findCount(query, t);
|
||||
}
|
||||
public <T> int findCountWithCopy(Query<T> query, Transaction t) {
|
||||
|
||||
public <T> int findRowCountWithCopy(Query<T> query, Transaction t) {
|
||||
|
||||
SpiOrmQueryRequest<T> request = createQueryRequest(Type.ROWCOUNT, query, t);
|
||||
SpiOrmQueryRequest<T> request = createQueryRequest(Type.COUNT, query, t);
|
||||
try {
|
||||
request.initTransIfRequired();
|
||||
return request.findRowCount();
|
||||
return request.findCount();
|
||||
|
||||
} finally {
|
||||
request.endTransIfRequired();
|
||||
@@ -1283,7 +1279,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
Transaction newTxn = createTransaction();
|
||||
|
||||
CallableQueryRowCount<T> call = new CallableQueryRowCount<>(this, copy, newTxn);
|
||||
CallableQueryCount<T> call = new CallableQueryCount<>(this, copy, newTxn);
|
||||
|
||||
QueryFutureRowCount<T> queryFuture = new QueryFutureRowCount<>(call);
|
||||
backgroundExecutor.execute(queryFuture.getFutureTask());
|
||||
|
||||
@@ -39,7 +39,7 @@ public interface OrmQueryEngine {
|
||||
/**
|
||||
* Execute the row count query.
|
||||
*/
|
||||
<T> int findRowCount(OrmQueryRequest<T> request);
|
||||
<T> int findCount(OrmQueryRequest<T> request);
|
||||
|
||||
/**
|
||||
* Execute the find id's query.
|
||||
|
||||
@@ -300,8 +300,8 @@ public final class OrmQueryRequest<T> extends BeanRequest implements BeanQueryRe
|
||||
return queryEngine.findId(this);
|
||||
}
|
||||
|
||||
public int findRowCount() {
|
||||
return queryEngine.findRowCount(this);
|
||||
public int findCount() {
|
||||
return queryEngine.findCount(this);
|
||||
}
|
||||
|
||||
public <A> List<A> findIds() {
|
||||
|
||||
@@ -66,7 +66,7 @@ public interface SpiOrmQueryRequest<T> extends DocQueryRequest<T> {
|
||||
/**
|
||||
* Execute the find row count query.
|
||||
*/
|
||||
int findRowCount();
|
||||
int findCount();
|
||||
|
||||
/**
|
||||
* Execute the find ids query.
|
||||
|
||||
@@ -66,11 +66,11 @@ public abstract class AbstractExpression implements SpiExpression {
|
||||
ElPropertyDeploy elProp = desc.getElPropertyDeploy(propertyName);
|
||||
if (elProp != null) {
|
||||
if (elProp.containsFormulaWithJoin()) {
|
||||
// for findRowCount query select clause
|
||||
// for findCount query select clause
|
||||
manyWhereJoin.addFormulaWithJoin(propertyName);
|
||||
}
|
||||
if (elProp.containsMany()) {
|
||||
// for findRowCount we join to a many property
|
||||
// for findCount we join to a many property
|
||||
manyWhereJoin.add(elProp);
|
||||
if (elProp.isAggregation()) {
|
||||
manyWhereJoin.setAggregation();
|
||||
|
||||
@@ -133,12 +133,12 @@ public class CQueryEngine {
|
||||
/**
|
||||
* Build and execute the row count query.
|
||||
*/
|
||||
public <T> int findRowCount(OrmQueryRequest<T> request) {
|
||||
public <T> int findCount(OrmQueryRequest<T> request) {
|
||||
|
||||
CQueryRowCount rcQuery = queryBuilder.buildRowCountQuery(request);
|
||||
try {
|
||||
|
||||
int rowCount = rcQuery.findRowCount();
|
||||
int count = rcQuery.findCount();
|
||||
|
||||
if (request.isLogSql()) {
|
||||
logGeneratedSql(request, rcQuery.getGeneratedSql(), rcQuery.getBindLog());
|
||||
@@ -152,7 +152,7 @@ public class CQueryEngine {
|
||||
request.getTransaction().end();
|
||||
}
|
||||
|
||||
return rowCount;
|
||||
return count;
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw CQuery.createPersistenceException(e, request.getTransaction(), rcQuery.getBindLog(), rcQuery.getGeneratedSql());
|
||||
|
||||
@@ -69,7 +69,7 @@ class CQueryRowCount {
|
||||
public String getSummary() {
|
||||
//noinspection StringBufferReplaceableByString
|
||||
StringBuilder sb = new StringBuilder(80);
|
||||
sb.append("FindRowCount exeMicros[").append(executionTimeMicros)
|
||||
sb.append("FindCount exeMicros[").append(executionTimeMicros)
|
||||
.append("] rows[").append(rowCount)
|
||||
.append("] type[").append(desc.getFullName())
|
||||
.append("] predicates[").append(predicates.getLogWhereSql())
|
||||
@@ -95,7 +95,7 @@ class CQueryRowCount {
|
||||
/**
|
||||
* Execute the query returning the row count.
|
||||
*/
|
||||
public int findRowCount() throws SQLException {
|
||||
public int findCount() throws SQLException {
|
||||
|
||||
long startNano = System.nanoTime();
|
||||
try {
|
||||
|
||||
+4
-4
@@ -7,17 +7,17 @@ import io.ebeaninternal.api.SpiQuery;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Represent the findRowCount query as a Callable.
|
||||
* Represent the findCount query as a Callable.
|
||||
*
|
||||
* @param <T> the entity bean type
|
||||
*/
|
||||
public class CallableQueryRowCount<T> extends CallableQuery<T> implements Callable<Integer> {
|
||||
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 CallableQueryRowCount(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
public CallableQueryCount(SpiEbeanServer server, SpiQuery<T> query, Transaction t) {
|
||||
super(server, query, t);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CallableQueryRowCount<T> extends CallableQuery<T> implements Callab
|
||||
*/
|
||||
public Integer call() throws Exception {
|
||||
try {
|
||||
return server.findRowCountWithCopy(query, transaction);
|
||||
return server.findCountWithCopy(query, transaction);
|
||||
} finally {
|
||||
// cleanup the underlying connection
|
||||
transaction.end();
|
||||
@@ -58,10 +58,10 @@ public class DefaultOrmQueryEngine implements OrmQueryEngine {
|
||||
return queryEngine.update(request);
|
||||
}
|
||||
|
||||
public <T> int findRowCount(OrmQueryRequest<T> request) {
|
||||
public <T> int findCount(OrmQueryRequest<T> request) {
|
||||
|
||||
flushJdbcBatchOnQuery(request);
|
||||
return queryEngine.findRowCount(request);
|
||||
return queryEngine.findCount(request);
|
||||
}
|
||||
|
||||
public <A> List<A> findIds(OrmQueryRequest<?> request) {
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.util.concurrent.FutureTask;
|
||||
*/
|
||||
public class QueryFutureRowCount<T> extends BaseFuture<Integer> implements FutureRowCount<T> {
|
||||
|
||||
private final CallableQueryRowCount<T> call;
|
||||
private final CallableQueryCount<T> call;
|
||||
|
||||
public QueryFutureRowCount(CallableQueryRowCount<T> call) {
|
||||
public QueryFutureRowCount(CallableQueryCount<T> call) {
|
||||
super(new FutureTask<>(call));
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user