What happens if you put a transaction inside a transaction in objectify/datastore? What is the order of execution and how do things resolve?
For example,
1) If the inner transaction fails, will the outer transaction also fail?
2) If the outer transaction fails, will the inner transaction be rolled back if it happened to finish?
// Outer Transaction
Thing th = ofy().transact(() -> {
Thing thing = ofy().load().key(thingKey).now();
thing.modify();
ofy().save().entity(thing);
// Inner Transaction
// This transaction could be in another method used in various other places
Thing th2 = ofy().transact(() -> {
Thing thing2 = ofy().load().key(thingKey2).now();
thing2.modify();
Thing thing2 = ofy().load().key(thingKey3).now();
thing3.modify();
ofy().save().entity(thing2);
ofy().save().entity(thing3);
return thing;
});
return thing;
});