If I want all deletes execute all-or-nothing.
- If nothing changed. Will the group of deletes be atomic?
- If I remove outer transaction, will something change?
- If I remove only inner transaction, will group be atomic?
- Ig I replace for-cycle with a batch delete and leave only outer transaction?
// inside event plan dao
public void delete(EventPlan eventPlan) {
final Objectify ofy = Objectify.beginTransaction();
try {
final ActivityDAO activityDao = new ActivityDAO();
for (final Activity activity : eventPlan.getActivities()) {
activityDao.delete(activity);
}
ofy.getTxn().commit();
} finally {
if (ofy.getTxn().isActive()) {
ofy.getTxn().rollback();
|
}
}
// inside activity dao
public void delete(Activity activity) {
final Objectify ofy = Objectify.beginTransaction();
try {
// do some logic in here, delete activity and commit txn
} finally {
// check and rollback as normal
}
}
If you use Objectify 3.1 then all transactions are XG-transactions, which can operate on max 5 different entity groups, i.e. if your Activities do not have common parent (= putting them in the same entity group) then you can only delete max five in one transaction.