#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
@@ -54,7 +54,7 @@ public class TestDataSourceMaxWithEntity extends BaseTestCase {
public void run() {
server.find(Customer.class).findRowCount();
server.find(Customer.class).findCount();
try {
System.out.println(position+" sleep " + sleepMillis);
Thread.sleep(sleepMillis);
@@ -29,7 +29,7 @@ public class TestFutureRowCountErrorHandling extends BaseTestCase {
.where().eq("doesNotExist", "this will fail")
.query();
FutureRowCount<Customer> futureRowCount = server.findFutureRowCount(query, null);
FutureRowCount<Customer> futureRowCount = server.findFutureCount(query, null);
QueryFutureRowCount<Customer> internalRowCount = (QueryFutureRowCount<Customer>)futureRowCount;
Transaction t = internalRowCount.getTransaction();
@@ -147,7 +147,7 @@ public class MainDbBoolean {
.setAutoTune(false)
.order("id");
int rc = query.findRowCount();
int rc = query.findCount();
Assert.assertTrue(rc > 0);
@@ -39,7 +39,7 @@ public class LinkQueryPublishTest {
.setMaxRows(10)
.findPagedList();
assertThat(pagedList.getTotalRowCount()).isEqualTo(3);
assertThat(pagedList.getTotalCount()).isEqualTo(3);
assertThat(pagedList.getList()).hasSize(3);
@@ -39,13 +39,13 @@ public class TestM2MDeleteWithCascade extends BaseTestCase {
List<Object> roleIds = new ArrayList<Object>();
Collections.addAll(roleIds, r0.getRoleid(), r1.getRoleid());
int rc = Ebean.find(MRole.class).where().idIn(roleIds).findRowCount();
int rc = Ebean.find(MRole.class).where().idIn(roleIds).findCount();
Assert.assertEquals("roles not deleted", 2, rc);
Ebean.deleteAll(roles);
rc = Ebean.find(MRole.class).where().idIn(roleIds).findRowCount();
rc = Ebean.find(MRole.class).where().idIn(roleIds).findCount();
Assert.assertEquals("roles deleted now", 0, rc);
}
@@ -25,7 +25,7 @@ public class ResetBasicData {
server.execute(new TxRunnable() {
public void run() {
if (server.find(Product.class).findRowCount() > 0) {
if (server.find(Product.class).findCount() > 0) {
// we can't really delete this base data as
// the test rely on the products being in there
return;
@@ -72,7 +72,7 @@ public class ResetBasicData {
public void insertCountries() {
if (server.find(Country.class).findRowCount() > 0) {
if (server.find(Country.class).findCount() > 0) {
return;
}
@@ -94,7 +94,7 @@ public class ResetBasicData {
public void insertProducts() {
if (server.find(Product.class).findRowCount() > 0) {
if (server.find(Product.class).findCount() > 0) {
return;
}
server.execute(new TxRunnable() {
@@ -18,7 +18,7 @@ public class TestInsertNoIdBean extends BaseTestCase {
Ebean.save(bean);
int rowCount = Ebean.find(NoIdBean.class).findRowCount();
int rowCount = Ebean.find(NoIdBean.class).findCount();
assertTrue("rowCount:"+rowCount, rowCount > 0);
@@ -18,7 +18,7 @@ public class TestTextJsonSelfRef extends BaseTestCase {
Ebean.execute(new TxRunnable() {
public void run() {
if (Ebean.find(SelfRefCustomer.class).findRowCount() == 0) {
if (Ebean.find(SelfRefCustomer.class).findCount() == 0) {
SelfRefCustomer c1 = new SelfRefCustomer();
c1.setName("Foo");
c1.setReferredBy(c1);
@@ -48,7 +48,7 @@ public class TestQueryFindFutureList extends BaseTestCase {
// wait for it to complete
List<Order> orders = futureList.getUnchecked();
assertEquals(Ebean.find(Order.class).findRowCount(), orders.size());
assertEquals(Ebean.find(Order.class).findCount(), orders.size());
}
@Test
@@ -61,7 +61,7 @@ public class TestQueryFindFutureList extends BaseTestCase {
// wait for it to complete
List<Order> orders = futureList.getUnchecked(1, TimeUnit.SECONDS);
assertEquals(Ebean.find(Order.class).findRowCount(), orders.size());
assertEquals(Ebean.find(Order.class).findCount(), orders.size());
}
}
@@ -83,7 +83,7 @@ public class TestQueryFindPagedList extends BaseTestCase {
pagedList.loadRowCount();
List<Order> orders = pagedList.getList();
int totalRowCount = pagedList.getTotalRowCount();
int totalRowCount = pagedList.getTotalCount();
assertThat(orders.size()).isLessThan(totalRowCount);
assertTrue(pagedList.hasNext());
@@ -96,9 +96,9 @@ public class TestQueryFindPagedList extends BaseTestCase {
.setMaxRows(3)
.findPagedList();
pagedList2.loadRowCount();
pagedList2.loadCount();
List<Order> orders2 = pagedList2.getList();
int totalRowCount2 = pagedList2.getTotalRowCount();
int totalRowCount2 = pagedList2.getTotalCount();
assertTrue(pagedList2.hasNext());
assertTrue(pagedList2.hasPrev());
@@ -161,11 +161,11 @@ public class TestQueryFindPagedList extends BaseTestCase {
PagedList<Order> pagedList = Ebean.find(Order.class).setMaxRows(3).findPagedList();
Future<Integer> rowCount = pagedList.getFutureRowCount();
Future<Integer> rowCount = pagedList.getFutureCount();
List<Order> orders = pagedList.getList();
// these are each getting the total row count
int totalRowCount = pagedList.getTotalRowCount();
int totalRowCount = pagedList.getTotalCount();
Integer totalRowCountWithTimeout = rowCount.get(30, TimeUnit.SECONDS);
Integer totalRowCountViaFuture = rowCount.get();
@@ -183,9 +183,9 @@ public class TestQueryFindPagedList extends BaseTestCase {
// fetch less that total orders (page size 3)
PagedList<Order> pagedList = Ebean.find(Order.class).setMaxRows(3).findPagedList();
pagedList.loadRowCount();
pagedList.loadCount();
List<Order> orders = pagedList.getList();
int totalRowCount = pagedList.getTotalRowCount();
int totalRowCount = pagedList.getTotalCount();
assertThat(orders.size()).isLessThan(totalRowCount);
}
@@ -207,10 +207,10 @@ public class TestQueryFindPagedList extends BaseTestCase {
try {
List<Order> orders = pagedList.getList();
int totalRowCount = pagedList.getTotalRowCount();
int totalRowCount = pagedList.getTotalCount();
// invoke it again but cached...
int totalRowCountAgain = pagedList.getTotalRowCount();
int totalRowCountAgain = pagedList.getTotalCount();
List<String> loggedSql = LoggedSqlCollector.stop();
@@ -242,7 +242,7 @@ public class TestQueryFindPagedList extends BaseTestCase {
LoggedSqlCollector.start();
pagedList.getTotalRowCount();
pagedList.getTotalCount();
pagedList.getList();
List<String> loggedSql = LoggedSqlCollector.stop();
@@ -29,7 +29,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
List<Order> list0 = query.findList();
Assert.assertEquals(rc0, list0.size());
int rc1 = query.findRowCount();
int rc1 = query.findCount();
Assert.assertEquals(rc0, rc1);
List<Object> ids1 = query.findIds();
@@ -48,7 +48,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
Query<Order> query2 = Ebean.find(Order.class).where().eq("status", Order.Status.NEW)
.ge("id", idGt).order().desc("id");
int rc2 = query2.findRowCount();
int rc2 = query2.findCount();
System.out.println("Expection Not same " + rc0 + " != " + rc2);
Assert.assertNotSame(rc0, rc2);
@@ -21,7 +21,7 @@ public class TestRowCount extends BaseTestCase {
Query<Order> query = Ebean.find(Order.class).fetch("details").where().gt("id", 1)
.gt("details.id", 1).order("id desc");
int rc = query.findRowCount();
int rc = query.findCount();
List<Object> ids = query.findIds();
@@ -44,7 +44,7 @@ public class TestDisjunctWhereOuterOnMany extends BaseTestCase {
.query();
List<UUOne> list = query.findList();
int rowCount = query.findRowCount();
int rowCount = query.findCount();
// select distinct t0.id c0, t0.name c1
// from uuone t0
@@ -31,7 +31,7 @@ public class TestFormulaWithFindCount extends BaseTestCase {
}
ExpressionList<Order> expressionList = server.find(Order.class).where().gt("totalAmount", 1d);
int rowCount = expressionList.findRowCount();
int rowCount = expressionList.findCount();
Assert.assertEquals(list.size(), rowCount);
}
@@ -28,7 +28,7 @@ public class TestObjectGraphNodeStatsCollection extends BaseTestCase {
MetaInfoManager infoManager = server.getMetaInfoManager();
server.find(Order.class).findRowCount();
server.find(Order.class).findCount();
infoManager.collectNodeStatistics(true);
infoManager.collectQueryPlanStatistics(true);
@@ -47,7 +47,7 @@ public class TestQueryConversationRowCount extends BaseTestCase {
LoggedSqlCollector.start();
query.findRowCount();
query.findCount();
// select count(*) from (
// select distinct t0.id c0
@@ -27,7 +27,7 @@ public class TestQueryRawExpressionMany extends BaseTestCase {
LoggedSqlCollector.start();
query.findRowCount();
query.findCount();
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql.get(0)).contains("select count(*) from ( select distinct t0.id c0 from o_order t0 left outer join o_order_detail t1 on t1.order_id = t0.id where t1.order_qty = ?)");
@@ -47,7 +47,7 @@ public class TestQueryRowCountWithMany extends BaseTestCase {
Assert.assertTrue(generatedSql.contains(" order by t0.cretime"));
int rowCount = query.findRowCount();
int rowCount = query.findCount();
// select count(*) from o_order t0
// left outer join o_order_detail t1 on t1.order_id = t0.id
@@ -84,7 +84,7 @@ public class TestQueryRowCountWithMany extends BaseTestCase {
.orderBy("cretime asc");
LoggedSqlCollector.start();
query.findRowCount();
query.findCount();
List<String> sqlLogged = LoggedSqlCollector.stop();
@@ -14,7 +14,7 @@ public class TestSelfParent extends BaseTestCase {
@Test
public void test() {
if (Ebean.find(SelfParent.class).findRowCount() > 0) {
if (Ebean.find(SelfParent.class).findCount() > 0) {
// only run once
return;
}
@@ -31,7 +31,7 @@ public class TestSoftDeletePagingList {
.setMaxRows(10)
.findPagedList();
int totalRowCount = pagedList.getTotalRowCount();
int totalRowCount = pagedList.getTotalCount();
List<Cover> resultList = pagedList.getList();
List<String> sql = LoggedSqlCollector.stop();
@@ -111,7 +111,7 @@ public class SqlQueryTests extends BaseTestCase {
ResetBasicData.reset();
int expectedRows = Ebean.find(Order.class).findRowCount();
int expectedRows = Ebean.find(Order.class).findCount();
final AtomicInteger count = new AtomicInteger();
@@ -56,7 +56,7 @@ public class TestOrderReportTotal extends BaseTestCase {
.where()
.gt("order.id", 2)
.istartsWith("order.customer.name","rob")
.findRowCount();
.findCount();
assertThat(detailsCount).isGreaterThan(0);
}
@@ -78,14 +78,14 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
Query<Customer> query = Ebean.find(Customer.class);
query.setRawSql(rawSql);
int initialRowCount = query.findRowCount();
int initialRowCount = query.findCount();
query.setFirstRow(1);
query.setMaxRows(2);
List<Customer> list = query.findList();
int rowCount = query.findRowCount();
FutureRowCount<Customer> futureRowCount = query.findFutureRowCount();
int rowCount = query.findCount();
FutureRowCount<Customer> futureRowCount = query.findFutureCount();
Assert.assertEquals(initialRowCount, rowCount);
Assert.assertEquals(initialRowCount, futureRowCount.get().intValue());
@@ -110,12 +110,12 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
Query<Customer> query = Ebean.find(Customer.class);
query.setRawSql(rawSql);
int initialRowCount = query.findRowCount();
int initialRowCount = query.findCount();
PagedList<Customer> page = query.setMaxRows(2).findPagedList();
List<Customer> list = page.getList();
int rowCount = page.getTotalRowCount();
int rowCount = page.getTotalCount();
Assert.assertEquals(2, list.size());
Assert.assertEquals(initialRowCount, rowCount);
@@ -186,7 +186,7 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
query.order("id desc");
PagedList<Order> pagedList = query.findPagedList();
pagedList.getList();
pagedList.getTotalRowCount();
pagedList.getTotalCount();
assertThat(query.getGeneratedSql()).contains("order by o.id desc limit 100");
}
@@ -71,7 +71,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
bean.setName("two");
Ebean.save(bean);
int rowCountBefore = Ebean.find(EBasicSoftDelete.class).findRowCount();
int rowCountBefore = Ebean.find(EBasicSoftDelete.class).findCount();
Ebean.delete(EBasicSoftDelete.class, bean.getId());
@@ -79,7 +79,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
// -- test .findRowCount()
LoggedSqlCollector.start();
int rowCountAfter = Ebean.find(EBasicSoftDelete.class).findRowCount();
int rowCountAfter = Ebean.find(EBasicSoftDelete.class).findCount();
List<String> loggedSql = LoggedSqlCollector.stop();
assertThat(loggedSql).hasSize(1);
@@ -91,7 +91,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
// -- test includeSoftDeletes().findRowCount()
LoggedSqlCollector.start();
int rowCountFull = Ebean.find(EBasicSoftDelete.class).setIncludeSoftDeletes().findRowCount();
int rowCountFull = Ebean.find(EBasicSoftDelete.class).setIncludeSoftDeletes().findCount();
assertThat(rowCountFull).isGreaterThan(rowCountAfter);
loggedSql = LoggedSqlCollector.stop();
@@ -197,7 +197,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
Ebean.find(EBasicSoftDelete.class)
.setId(bean.getId())
.where()
.includeSoftDeletes()
.setIncludeSoftDeletes()
.findUnique();
assertThat(fetchAllWithLazy.getChildren()).hasSize(3);
@@ -70,7 +70,7 @@ public class TestExplicitTransactionMode extends BaseTestCase {
}
// rollback as expected
assertEquals(0, ebeanServer.find(UTMaster.class).findRowCount());
assertEquals(0, ebeanServer.find(UTMaster.class).findCount());
UTMaster bean1 = new UTMaster("one1");
UTMaster bean2 = new UTMaster("two2");
@@ -25,11 +25,11 @@ public class TestNestedBeginRequired extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.required());
try {
server.find(Country.class).findRowCount();
server.find(Country.class).findCount();
someInnerMethod();
server.find(Product.class).findRowCount();
server.find(Product.class).findCount();
txn.commit();
@@ -45,7 +45,7 @@ public class TestNestedBeginRequired extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.required());
try {
server.find(Customer.class).findRowCount();
server.find(Customer.class).findCount();
txn.commit();
@@ -23,12 +23,12 @@ public class TestNestedBeginRequiredWithFailure extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.required());
try {
server.find(Country.class).findRowCount();
server.find(Country.class).findCount();
try {
someInnerMethodWithFailure();
server.find(Product.class).findRowCount();
server.find(Product.class).findCount();
txn.commit();
} catch (RuntimeException e) {
@@ -50,7 +50,7 @@ public class TestNestedBeginRequiredWithFailure extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.required());
try {
server.find(Customer.class).findRowCount();
server.find(Customer.class).findCount();
EBasic basic = new EBasic();
basic.setName("ignore");
@@ -25,11 +25,11 @@ public class TestNestedBeginRequiresNew extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.requiresNew());
try {
server.find(Country.class).findRowCount();
server.find(Country.class).findCount();
someInnerMethod();
server.find(Product.class).findRowCount();
server.find(Product.class).findCount();
txn.commit();
@@ -45,7 +45,7 @@ public class TestNestedBeginRequiresNew extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.requiresNew());
try {
server.find(Customer.class).findRowCount();
server.find(Customer.class).findCount();
txn.commit();
} finally {
@@ -25,14 +25,14 @@ public class TestNestedBeginRequiresNewWithFailure extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.requiresNew());
try {
server.find(Country.class).findRowCount();
server.find(Country.class).findCount();
try {
someInnerMethodWithFailure();
} catch (RuntimeException e) {
logger.info("Inner method failed with " + e.getMessage());
}
server.find(Product.class).findRowCount();
server.find(Product.class).findCount();
txn.commit();
@@ -48,7 +48,7 @@ public class TestNestedBeginRequiresNewWithFailure extends BaseTestCase {
Transaction txn = server.beginTransaction(TxScope.requiresNew());
try {
server.find(Customer.class).findRowCount();
server.find(Customer.class).findCount();
if (server != null) {
throw new RuntimeException("barf");