google app engine - Objectify - ofy() in method defined outside of transaction -


a basic transaction looks this:

import static com.googlecode.objectify.objectifyservice.ofy; import com.googlecode.objectify.work;  // if don't need return value, can use voidwork thing th = ofy().transact(new work<thing>() {     public thing run() {         thing thing = ofy().load().key(thingkey).now();         thing.modify();         ofy().save().entity(thing);     } }); 

when ofy().load() , other ofy() methods called within transaction have benefits of transaction, such being atomic. however, using util method contains ofy() method escape transaction? following.

// if don't need return value, can use voidwork thing th = ofy().transact(new work<thing>() {     public thing run() {         util.modify(thingkey);     } }); 

where util defined somewhere so.

public class util {      public static modify(thingkey) {         thing thing = ofy().load().key(thingkey).now();         thing.modify();         ofy().save().entity(thing);     }  } 

the 2 cases describe equivalent.

if wish run outside of transaction objectify provides .transactionless() method "escape" transactional context.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -