#326 - API Addition - saveAll(), deleteAll() etc

This commit is contained in:
Robin Bygrave
2015-07-20 09:42:05 +12:00
parent 776e48a501
commit 89bed8be67
6 changed files with 296 additions and 47 deletions
@@ -727,4 +727,49 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
public JsonContext json() {
return null;
}
@Override
public int saveAll(Collection<?> beans) throws OptimisticLockException {
return 0;
}
@Override
public int deleteAll(Collection<?> beans) throws OptimisticLockException {
return 0;
}
@Override
public void deleteAll(Class<?> beanType, Collection<?> ids) {
}
@Override
public void deleteAll(Class<?> beanType, Collection<?> ids, Transaction transaction) {
}
@Override
public int saveAll(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
return 0;
}
@Override
public void updateAll(Collection<?> beans) throws OptimisticLockException {
}
@Override
public void updateAll(Collection<?> beans, Transaction transaction) throws OptimisticLockException {
}
@Override
public void insertAll(Collection<?> beans) {
}
@Override
public void insertAll(Collection<?> beans, Transaction transaction) {
}
}
@@ -25,7 +25,7 @@ public class TestInsertCollection extends BaseTestCase {
customers.add(cust1);
customers.add(cust2);
Ebean.insert(customers);
Ebean.insertAll(customers);
Assert.assertNotNull(cust1.getId());
Assert.assertNotNull(cust2.getId());
@@ -38,7 +38,7 @@ public class TestInsertCollection extends BaseTestCase {
cust1.setName("jim-changed");
cust2.setName("bob-changed");
Ebean.update(customers);
Ebean.updateAll(customers);
Customer cust1Check2 = Ebean.find(Customer.class, cust1.getId());
Assert.assertEquals("jim-changed", cust1Check2.getName());
@@ -62,6 +62,17 @@ public class TestInsertCollection extends BaseTestCase {
Customer cust3Check = Ebean.find(Customer.class, cust3.getId());
Assert.assertEquals("mac", cust3Check.getName());
List<Customer> deleteList = new ArrayList<Customer>();
deleteList.add(cust1Check3);
deleteList.add(cust3);
deleteList.add(cust2Check2);
Ebean.deleteAll(deleteList);
Assert.assertNull(Ebean.find(Customer.class, cust1Check3.getId()));
Assert.assertNull(Ebean.find(Customer.class, cust2Check2.getId()));
Assert.assertNull(Ebean.find(Customer.class, cust3.getId()));
}