use of io.requery.query.element.QueryType.DELETE in project requery by requery.
the class EntityDataStore method delete.
@Override
public <E extends T> Void delete(Iterable<E> entities) {
if (entities instanceof Result) {
// work around for sqlite since the read cursor can't be open during the transaction
@SuppressWarnings("unchecked") Result<E> result = (Result<E>) entities;
entities = result.toList();
}
Iterator<E> iterator = entities.iterator();
if (iterator.hasNext()) {
try (TransactionScope transaction = new TransactionScope(transactionProvider)) {
E entity = iterator.next();
EntityProxy<E> proxy = context.proxyOf(entity, true);
EntityWriter<E, T> writer = context.write(proxy.type().getClassType());
writer.delete(entities);
transaction.commit();
}
}
return null;
}