diff --git a/.gitignore b/.gitignore index 65e36c5ce..6cbadb2b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.autofetch *.sql +*.orig .classpath .project .settings/ diff --git a/src/main/java/com/avaje/ebean/Ebean.java b/src/main/java/com/avaje/ebean/Ebean.java index 17d7f2d05..5df6a1026 100644 --- a/src/main/java/com/avaje/ebean/Ebean.java +++ b/src/main/java/com/avaje/ebean/Ebean.java @@ -559,10 +559,20 @@ public final class Ebean { } /** + * Deprecated - please migrate to insertAll(). + * * Insert a collection of beans. */ + @Deprecated public static void insert(Collection> beans) { - serverMgr.getDefaultServer().insert(beans); + serverMgr.getDefaultServer().insertAll(beans); + } + + /** + * Insert a collection of beans. + */ + public static void insertAll(Collection> beans) { + serverMgr.getDefaultServer().insertAll(beans); } /** @@ -630,24 +640,46 @@ public final class Ebean { } /** + * Deprecate - please migrate to updateAll(). + * * Update the beans in the collection. */ + @Deprecated public static void update(Collection> beans) throws OptimisticLockException { - serverMgr.getDefaultServer().update(beans); + serverMgr.getDefaultServer().updateAll(beans); } /** + * Update the beans in the collection. + */ + public static void updateAll(Collection> beans) throws OptimisticLockException { + serverMgr.getDefaultServer().updateAll(beans); + } + + /** + * Deprecated - please change to iterate yourself and save(). + * * Save all the beans from an Iterator. */ + @Deprecated public static int save(Iterator> iterator) throws OptimisticLockException { return serverMgr.getDefaultServer().save(iterator); } /** + * Deprecated - please migrate to saveAll(). + * * Save all the beans from a Collection. */ public static int save(Collection> beans) throws OptimisticLockException { - return serverMgr.getDefaultServer().save(beans); + return serverMgr.getDefaultServer().saveAll(beans); + } + + /** + * Save all the beans from a Collection. + */ + public static int saveAll(Collection> beans) throws OptimisticLockException { + return serverMgr.getDefaultServer().saveAll(beans); } /** @@ -721,10 +753,13 @@ public final class Ebean { } /** + * Deprecated - please migrate to deleteAll(). + * * Delete several beans given their type and id values. */ + @Deprecated public static void delete(Class> beanType, Collection> ids) { - serverMgr.getDefaultServer().delete(beanType, ids); + serverMgr.getDefaultServer().deleteAll(beanType, ids); } /** @@ -737,8 +772,16 @@ public final class Ebean { /** * Delete all the beans from a Collection. */ - public static int delete(Collection> c) throws OptimisticLockException { - return delete(c.iterator()); + @Deprecated + public static int delete(Collection> beans) throws OptimisticLockException { + return serverMgr.getDefaultServer().deleteAll(beans); + } + + /** + * Delete all the beans in the Collection. + */ + public static int deleteAll(Collection> beans) throws OptimisticLockException { + return serverMgr.getDefaultServer().deleteAll(beans); } /** @@ -1441,8 +1484,7 @@ public final class Ebean { * @param deletes * true if rows on the table where deleted */ - public static void externalModification(String tableName, boolean inserts, boolean updates, - boolean deletes) { + public static void externalModification(String tableName, boolean inserts, boolean updates, boolean deletes) { serverMgr.getDefaultServer().externalModification(tableName, inserts, updates, deletes); } diff --git a/src/main/java/com/avaje/ebean/EbeanServer.java b/src/main/java/com/avaje/ebean/EbeanServer.java index 300e2f60a..bfc865434 100644 --- a/src/main/java/com/avaje/ebean/EbeanServer.java +++ b/src/main/java/com/avaje/ebean/EbeanServer.java @@ -1223,14 +1223,25 @@ public interface EbeanServer { void save(Object bean) throws OptimisticLockException; /** + * Deprecated - please change to iterate yourself and save. + * * Save all the beans in the iterator. */ + @Deprecated int save(Iterator> it) throws OptimisticLockException; + /** + * Deprecated - please migrate to saveAll(). + * + * Save all the beans in the collection. + */ + @Deprecated + int save(Collection> beans) throws OptimisticLockException; + /** * Save all the beans in the collection. */ - int save(Collection> beans) throws OptimisticLockException; + int saveAll(Collection> beans) throws OptimisticLockException; /** * Delete the bean. @@ -1242,14 +1253,25 @@ public interface EbeanServer { void delete(Object bean) throws OptimisticLockException; /** + * Deprecated - please change to iterate yourself and delete. + * * Delete all the beans from an Iterator. */ + @Deprecated int delete(Iterator> it) throws OptimisticLockException; + /** + * Deprecated - please migrate to deleteAll(). + * + * Delete all the beans in the collection. + */ + @Deprecated + int delete(Collection> beans) throws OptimisticLockException; + /** * Delete all the beans in the collection. */ - int delete(Collection> c) throws OptimisticLockException; + int deleteAll(Collection> beans) throws OptimisticLockException; /** * Delete the bean given its type and id. @@ -1262,15 +1284,45 @@ public interface EbeanServer { int delete(Class> beanType, Object id, Transaction transaction); /** + * Deprecated - please migrate to deleteAll(). + * * Delete several beans given their type and id values. */ + @Deprecated void delete(Class> beanType, Collection> ids); + /** + * Delete several beans given their type and id values. + */ + void deleteAll(Class> beanType, Collection> ids); + + /** + * Deprecated - please migrate to deleteAll(). + * + * Delete several beans given their type and id values with an explicit + * transaction. + */ + @Deprecated + void delete(Class> beanType, Collection> ids, Transaction transaction); + /** * Delete several beans given their type and id values with an explicit * transaction. */ - void delete(Class> beanType, Collection> ids, Transaction transaction); + void deleteAll(Class> beanType, Collection> ids, Transaction transaction); + + /** + * Delete the bean with an explicit transaction. + */ + void delete(Object bean, Transaction transaction) throws OptimisticLockException; + + /** + * Deprecated - please migrate to iterate yourself and delete(). + * + * Delete all the beans from an iterator. + */ + @Deprecated + int delete(Iterator> it, Transaction transaction) throws OptimisticLockException; /** * Execute a Sql Update Delete or Insert statement. This returns the number of @@ -1413,14 +1465,24 @@ public interface EbeanServer { void save(Object bean, Transaction transaction) throws OptimisticLockException; /** + * Deprecated - please change to iterate yourself and save. * Save all the beans in the iterator with an explicit transaction. */ + @Deprecated int save(Iterator> it, Transaction transaction) throws OptimisticLockException; + /** + * Deprecated - please migrate to saveAll(). + * + * Save all the beans in the collection with an explicit transaction. + */ + @Deprecated + int save(Collection> beans, Transaction transaction) throws OptimisticLockException; + /** * Save all the beans in the collection with an explicit transaction. */ - int save(Collection> beans, Transaction transaction) throws OptimisticLockException; + int saveAll(Collection> beans, Transaction transaction) throws OptimisticLockException; /** * Marks the entity bean as dirty. @@ -1502,16 +1564,33 @@ public interface EbeanServer { void update(Object bean, Transaction transaction, boolean deleteMissingChildren) throws OptimisticLockException; /** + * Deprecated - please migrate to updateAll(). + * * Update a collection of beans. If there is no current transaction one is created and used to * update all the beans in the collection. */ + @Deprecated void update(Collection> beans) throws OptimisticLockException; + /** + * Update a collection of beans. If there is no current transaction one is created and used to + * update all the beans in the collection. + */ + void updateAll(Collection> beans) throws OptimisticLockException; + + /** + * Deprecated - please migrate to updateAll(). + * + * Update a collection of beans with an explicit transaction. + */ + @Deprecated + void update(Collection> beans, Transaction transaction) throws OptimisticLockException; + /** * Update a collection of beans with an explicit transaction. */ - void update(Collection> beans, Transaction transaction) throws OptimisticLockException; - + void updateAll(Collection> beans, Transaction transaction) throws OptimisticLockException; + /** * Insert the bean. *
@@ -1528,15 +1607,32 @@ public interface EbeanServer { void insert(Object bean, Transaction transaction); /** + * Deprecated - please migrate to insertAll(). + * * Insert a collection of beans. If there is no current transaction one is created and used to * insert all the beans in the collection. */ + @Deprecated void insert(Collection> beans); + /** + * Insert a collection of beans. If there is no current transaction one is created and used to + * insert all the beans in the collection. + */ + void insertAll(Collection> beans); + + /** + * Deprecated - please migrate to insertAll(). + * + * Insert a collection of beans with an explicit transaction. + */ + @Deprecated + void insert(Collection> beans, Transaction transaction); + /** * Insert a collection of beans with an explicit transaction. */ - void insert(Collection> beans, Transaction transaction); + void insertAll(Collection> beans, Transaction transaction); /** * Delete the associations (from the intersection table) of a ManyToMany given @@ -1545,7 +1641,7 @@ public interface EbeanServer { * Typically these deletions occur automatically when persisting a ManyToMany * collection and this provides a way to invoke those deletions directly. *
- * + * * @return the number of associations deleted (from the intersection table). */ int deleteManyToManyAssociations(Object ownerBean, String propertyName); @@ -1560,7 +1656,7 @@ public interface EbeanServer { * Typically these deletions occur automatically when persisting a ManyToMany * collection and this provides a way to invoke those deletions directly. * - * + * * @return the number of associations deleted (from the intersection table). */ int deleteManyToManyAssociations(Object ownerBean, String propertyName, Transaction transaction); @@ -1624,15 +1720,6 @@ public interface EbeanServer { */ void saveAssociation(Object ownerBean, String propertyName, Transaction transaction); - /** - * Delete the bean with an explicit transaction. - */ - void delete(Object bean, Transaction transaction) throws OptimisticLockException; - - /** - * Delete all the beans from an iterator. - */ - int delete(Iterator> it, Transaction transaction) throws OptimisticLockException; /** * Execute explicitly passing a transaction. diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java index 5f302bc94..d249a1285 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/DefaultServer.java @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; import javax.management.InstanceAlreadyExistsException; import javax.management.MBeanServer; import javax.management.ObjectName; +import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -1171,7 +1172,7 @@ public final class DefaultServer implements SpiEbeanServer { BeanDescriptor