2016-04-18 4 views

答えて

1

残念ながらObjectifyにはこのような機能はありません。しかし、あなた自身で同様のものを実装することができます。

public Something getOrInsert(Something s) {  
    return ofy().transact(new Work<Something>() { 
     public Something run() { 
      Something something = ofy().load().type(Something.class).id(s.getId()).now(); 
      if(something != null) { 
       return something; 
      } 

      ofy().save().entity(s); 

      return s; 
     } 
    }); 
} 
関連する問題