Advertisement
Guest User

Untitled

a guest
Dec 16th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public static Thing updateA( final String uid, final int value ) {
  2.  
  3.     return ofy().transact(new Work<Thing>() {
  4.         @Override
  5.         public Thing run() {
  6.             Thing thing = ofy().load().type(Thing.class).id(uid).safe();
  7.             if (thing.a != value) {
  8.                 thing.a = value;
  9.                 ofy().save().entity(thing);
  10.             } else {
  11.         // there is no save() required here and I get away with 1 operation cheaper, yet all is serial and safe?
  12.             }
  13.             return thing;
  14.         }
  15.     });
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement