I have a datastore with a kind "shop", a kind "order" and a kind "transaction".
One shop has many orders, and one order has many transactions.
The parent of a transaction is an order, the parent of an order is a shop.
I want to delete all entries in the transactions table:
public void cleanUp() {
Query query = new Query(TransactionDBFields.TRANSACTION_TABLE_NAME);
query.setKeysOnly();
query.setFilter(
new Query.FilterPredicate(
TransactionDBFields.CREATED_AT,
Query.FilterOperator.LESS_THAN_OR_EQUAL,
new Date())
);
PreparedQuery preparedQuery = datastore.prepare(query);
Iterable<Entity> entities = preparedQuery.asIterable(FetchOptions.Builder.withLimit(5));
TransactionOptions options = TransactionOptions.Builder.withXG(true);
Transaction txn = datastore.beginTransaction(options);
for (Entity en : entities) {
datastore.delete(txn, en.getKey());
}
txn.commit();
}
If I change the limit to anything larger than 5 I get the error:
java.lang.IllegalArgumentException: operating on too many entity groups in a single transaction.
- apparently as GAE does not allow operating on more than 5 entity groups in a single transaction.
Is there a way to delete more than 5 entities at a time? executing the above code continuously to delete all transaction entities does not seem reasonable, nor when considering performance.
-Louise