#788 - Deprecate findRowCount() ... add findCount(). Effectively renaming findRowCount() to findCount()

This commit is contained in:
Robin Bygrave
2016-07-31 19:06:21 +12:00
parent 7c83010df1
commit dc7c854432
37 changed files with 175 additions and 81 deletions
@@ -741,8 +741,8 @@ public interface EbeanServer {
/**
* Return the number of 'top level' or 'root' entities this query should return.
*
* @see Query#findRowCount()
* @see com.avaje.ebean.Query#findFutureRowCount()
* @see Query#findCount()
* @see Query#findFutureCount()
*/
<T> int findCount(Query<T> query, Transaction transaction);
@@ -182,6 +182,13 @@ public interface ExpressionList<T> {
* This is the number of 'top level' or 'root level' entities.
* </p>
*/
int findCount();
/**
* Deprecated in favor of findCount().
*
* @deprecated
*/
int findRowCount();
/**
@@ -228,6 +235,13 @@ public interface ExpressionList<T> {
*
* @return a Future object for the row count query
*/
FutureRowCount<T> findFutureCount();
/**
* Deprecated in favor of findFutureCount().
*
* @deprecated
*/
FutureRowCount<T> findFutureRowCount();
/**
+21 -4
View File
@@ -677,19 +677,36 @@ public abstract class Model {
/**
* Executes a find row count query in a background thread.
* <p>
* Equivalent to {@link Query#findFutureRowCount()}
* Equivalent to {@link Query#findFutureCount()}
*/
public FutureRowCount<T> findFutureCount() {
return query().findFutureCount();
}
/**
* Deprecated in favor of findFutureCount().
* <p>
* Equivalent to {@link Query#findFutureCount()}
*/
public FutureRowCount<T> findFutureRowCount() {
return query().findFutureRowCount();
return query().findFutureCount();
}
/**
* Returns the total number of entities for this type. *
* <p>
* Equivalent to {@link Query#findRowCount()}
* Equivalent to {@link Query#findCount()}
*/
public int findCount() {
return query().findCount();
}
/**
* Deprecated in favor of findCount().
* @deprecated
*/
public int findRowCount() {
return query().findRowCount();
return query().findCount();
}
/**
@@ -110,6 +110,13 @@ public interface PagedList<T> {
* wrapped in the unchecked PersistenceException (which might be preferrable).
* </p>
*/
void loadCount();
/**
* Deprecated in favor of loadCount().
*
* @deprecated
*/
void loadRowCount();
/**
@@ -138,6 +145,13 @@ public interface PagedList<T> {
*
* }</pre>
*/
Future<Integer> getFutureCount();
/**
* Deprecated in favor of getFutureCount().
*
* @deprecated
*/
Future<Integer> getFutureRowCount();
/**
@@ -170,6 +184,13 @@ public interface PagedList<T> {
*
* }</pre>
*/
int getTotalCount();
/**
* Deprecated in favor of getTotalCount().
*
* @deprecated
*/
int getTotalRowCount();
/**
@@ -323,9 +323,14 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return query.findFutureIds();
}
@Override
public FutureRowCount<T> findFutureCount() {
return query.findFutureCount();
}
@Override
public FutureRowCount<T> findFutureRowCount() {
return query.findFutureRowCount();
return findFutureCount();
}
@Override
@@ -338,9 +343,14 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
return query.findPagedList();
}
@Override
public int findCount() {
return query.findCount();
}
@Override
public int findRowCount() {
return query.findRowCount();
return findCount();
}
@Override
@@ -48,9 +48,14 @@ public class FilterExpressionList<T> extends DefaultExpressionList<T> {
return rootQuery.findFutureList();
}
@Override
public FutureRowCount<T> findFutureCount() {
return rootQuery.findFutureCount();
}
@Override
public FutureRowCount<T> findFutureRowCount() {
return rootQuery.findFutureRowCount();
return findFutureCount();
}
@Override
@@ -63,9 +68,14 @@ public class FilterExpressionList<T> extends DefaultExpressionList<T> {
return rootQuery.findMap();
}
@Override
public int findCount() {
return rootQuery.findCount();
}
@Override
public int findRowCount() {
return rootQuery.findRowCount();
return findCount();
}
@Override
@@ -360,9 +360,14 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
return exprList.findFutureList();
}
@Override
public FutureRowCount<T> findFutureCount() {
return exprList.findFutureCount();
}
@Override
public FutureRowCount<T> findFutureRowCount() {
return exprList.findFutureRowCount();
return findFutureCount();
}
@Override
@@ -401,10 +406,15 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
}
@Override
public int findRowCount() {
public int findCount() {
return exprList.findRowCount();
}
@Override
public int findRowCount() {
return findCount();
}
@Override
public Set<T> findSet() {
return exprList.findSet();
@@ -43,19 +43,27 @@ public class LimitOffsetPagedList<T> implements PagedList<T> {
this.firstRow = query.getFirstRow();
}
public void loadRowCount() {
getFutureRowCount();
public void loadCount() {
getFutureCount();
}
public Future<Integer> getFutureRowCount() {
public void loadRowCount() {
loadCount();
}
public Future<Integer> getFutureCount() {
synchronized (monitor) {
if (futureRowCount == null) {
futureRowCount = server.findFutureRowCount(query, null);
futureRowCount = server.findFutureCount(query, null);
}
return futureRowCount;
}
}
public Future<Integer> getFutureRowCount() {
return getFutureCount();
}
public List<T> getList() {
synchronized (monitor) {
if (list == null) {
@@ -67,7 +75,7 @@ public class LimitOffsetPagedList<T> implements PagedList<T> {
public int getTotalPageCount() {
int rowCount = getTotalRowCount();
int rowCount = getTotalCount();
if (rowCount == 0) {
return 0;
} else {
@@ -75,7 +83,7 @@ public class LimitOffsetPagedList<T> implements PagedList<T> {
}
}
public int getTotalRowCount() {
public int getTotalCount() {
synchronized (monitor) {
if (futureRowCount != null) {
try {
@@ -89,13 +97,17 @@ public class LimitOffsetPagedList<T> implements PagedList<T> {
if (foregroundTotalRowCount > -1) return foregroundTotalRowCount;
// just using foreground thread
foregroundTotalRowCount = server.findRowCount(query, null);
foregroundTotalRowCount = server.findCount(query, null);
return foregroundTotalRowCount;
}
}
public int getTotalRowCount() {
return getTotalCount();
}
public boolean hasNext() {
return (firstRow + maxRows) < getTotalRowCount();
return (firstRow + maxRows) < getTotalCount();
}
public boolean hasPrev() {
@@ -110,7 +122,7 @@ public class LimitOffsetPagedList<T> implements PagedList<T> {
int first = firstRow + 1;
int last = firstRow + getList().size();
int total = getTotalRowCount();
int total = getTotalCount();
return first + to + last + of + total;
}