#802 - Find generics on findIds() - refactor internals of find ids to use find single attribute

This commit is contained in:
Robin Bygrave
2016-08-04 17:28:41 +12:00
parent 1be30f1671
commit 3c6eab6c85
25 changed files with 162 additions and 463 deletions
@@ -186,7 +186,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
}
@Override
public <T> List<Object> findIdsWithCopy(Query<T> query, Transaction t) {
public <A> List<A> findIdsWithCopy(Query<?> query, Transaction t) {
return null;
}
@@ -466,7 +466,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
}
@Override
public <T> List<Object> findIds(Query<T> query, Transaction transaction) {
public <A> List<A> findIds(Query<?> query, Transaction transaction) {
return null;
}
@@ -1,17 +1,17 @@
package com.avaje.tests.basic;
import java.util.List;
import java.util.concurrent.ExecutionException;
import org.junit.Assert;
import org.junit.Test;
import com.avaje.ebean.BaseTestCase;
import com.avaje.ebean.Ebean;
import com.avaje.ebean.FutureIds;
import com.avaje.ebean.Query;
import com.avaje.tests.model.basic.Order;
import com.avaje.tests.model.basic.ResetBasicData;
import org.junit.Test;
import java.util.List;
import java.util.concurrent.ExecutionException;
import static org.assertj.core.api.Assertions.assertThat;
public class TestFetchId extends BaseTestCase {
@@ -28,19 +28,12 @@ public class TestFetchId extends BaseTestCase {
.query();
List<Object> ids = Ebean.getServer(null).findIds(query, null);
assertThat(ids).isNotEmpty();
FutureIds<Order> futureIds = Ebean.getServer(null).findFutureIds(query,null);
// this list is likely empty at this point and
// will get populated in the background
List<Object> partial = futureIds.getPartialIds();
// this is likely 0 or a small number
// wait for all the id's to be fetched
List<Object> idList = futureIds.get();
Assert.assertTrue("same instance", partial == idList);
Assert.assertTrue("sz > 0", !ids.isEmpty());
assertThat(idList).isNotEmpty();
}
}
@@ -23,7 +23,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
int rc0 = query.findRowCount();
List<Object> ids = query.findIds();
List<Integer> ids = query.findIds();
Assert.assertEquals(rc0, ids.size());
List<Order> list0 = query.findList();
@@ -32,7 +32,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
int rc1 = query.findCount();
Assert.assertEquals(rc0, rc1);
List<Object> ids1 = query.findIds();
List<Integer> ids1 = query.findIds();
Assert.assertEquals(rc0, ids1.size());
List<Order> list1 = query.findList();
@@ -53,7 +53,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
System.out.println("Expection Not same " + rc0 + " != " + rc2);
Assert.assertNotSame(rc0, rc2);
List<Object> ids2 = query2.findIds();
List<Integer> ids2 = query2.findIds();
Assert.assertEquals(rc2, ids2.size());
List<Order> list2 = query2.findList();
@@ -20,8 +20,7 @@ public class TestFindIdsWithInheritance extends BaseTestCase {
Ebean.save(truck);
List<Object> ids = Ebean.find(Vehicle.class).findIds();
List<Integer> ids = Ebean.find(Vehicle.class).findIds();
Assert.assertNotNull(ids);
Ebean.delete(truck);
@@ -95,7 +95,7 @@ public class TestObjectGraphNodeStatsCollection extends BaseTestCase {
ResetBasicData.reset();
List<Object> ids = Ebean.find(Order.class).findIds();
List<Integer> ids = Ebean.find(Order.class).findIds();
Assert.assertTrue(!ids.isEmpty());
}