#367 - ENH: Add EbeanServer deleteAll() with an explicit transaction

This commit is contained in:
Robin Bygrave
2015-08-02 12:43:19 +12:00
parent 4327108ddf
commit fceeeacf88
4 changed files with 154 additions and 9 deletions
+12 -8
View File
@@ -1205,7 +1205,6 @@ public interface EbeanServer {
* public class Order { ...
*
* @OneToMany(cascade=CascadeType.ALL, mappedBy="order")
* @JoinColumn(name="order_id")
* List<OrderDetail> details;
* ...
* }
@@ -1235,9 +1234,9 @@ public interface EbeanServer {
void delete(Object bean) throws OptimisticLockException;
/**
* Delete all the beans in the collection.
* Delete the bean with an explicit transaction.
*/
int deleteAll(Collection<?> beans) throws OptimisticLockException;
void delete(Object bean, Transaction transaction) throws OptimisticLockException;
/**
* Delete the bean given its type and id.
@@ -1249,6 +1248,16 @@ public interface EbeanServer {
*/
int delete(Class<?> beanType, Object id, Transaction transaction);
/**
* Delete all the beans in the collection.
*/
int deleteAll(Collection<?> beans) throws OptimisticLockException;
/**
* Delete all the beans in the collection using an explicit transaction.
*/
int deleteAll(Collection<?> beans, Transaction transaction) throws OptimisticLockException;
/**
* Delete several beans given their type and id values.
*/
@@ -1260,11 +1269,6 @@ public interface EbeanServer {
*/
void deleteAll(Class<?> beanType, Collection<?> ids, Transaction transaction);
/**
* Delete the bean with an explicit transaction.
*/
void delete(Object bean, Transaction transaction) throws OptimisticLockException;
/**
* Execute a Sql Update Delete or Insert statement. This returns the number of
* rows that where updated, deleted or inserted. If is executed in batch then
@@ -1180,7 +1180,7 @@ public final class DefaultServer implements SpiEbeanServer {
BeanDescriptor<T> desc = beanDescriptorManager.getBeanDescriptor(query.getBeanType());
T bean = desc.cacheNaturalKeyLookup((SpiQuery<T>)query, (SpiTransaction) t);
T bean = desc.cacheNaturalKeyLookup((SpiQuery<T>) query, (SpiTransaction) t);
if (bean != null) {
return bean;
}
@@ -1779,6 +1779,14 @@ public final class DefaultServer implements SpiEbeanServer {
return deleteAllInternal(beans.iterator(), null);
}
/**
* Delete all the beans in the collection.
*/
@Override
public int deleteAll(Collection<?> beans, Transaction t) {
return deleteAllInternal(beans.iterator(), t);
}
/**
* Delete all the beans in the iterator with an explicit transaction.
*/