#1936 - ENH: Add saveAll(Object... beans) ... using varargs for DB and Database

This commit is contained in:
rob bygrave
2020-02-07 16:10:11 +13:00
parent 62b1da1be2
commit 3e43d544fb
5 changed files with 51 additions and 0 deletions
+7
View File
@@ -454,6 +454,13 @@ public class DB {
return getDefault().saveAll(beans);
}
/**
* Save all the beans from a Collection.
*/
public static int saveAll(Object... beans) throws OptimisticLockException {
return getDefault().saveAll(beans);
}
/**
* This method checks the uniqueness of a bean. I.e. if the save will work. It will return the
* properties that violates an unique / primary key. This may be done in an UI save action to
+5
View File
@@ -881,6 +881,11 @@ public interface Database {
*/
int saveAll(Collection<?> beans) throws OptimisticLockException;
/**
* Save all the beans.
*/
int saveAll(Object... beans) throws OptimisticLockException;
/**
* Delete the bean.
* <p>
@@ -131,6 +131,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -1916,6 +1917,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return saveAllInternal(beans, null);
}
@Override
public int saveAll(Object... beans) throws OptimisticLockException {
return saveAllInternal(Arrays.asList(beans), null);
}
/**
* Save all beans in the iterator with an explicit transaction.
*/