开发者

Updating multiple entities in google appengine

开发者 https://www.devze.com 2023-02-07 11:40 出处:网络
I\'m using google appengine with java. I have two Entities: a and b, where a has a list of b\'s. Now, I want to do the following:

I'm using google appengine with java. I have two Entities: a and b, where a has a list of b's. Now, I want to do the following:

try{
 //start transaction
 a1 = getA();
 a2 = getA();
 b1 = new B();
 b2 = new B();
 a1开发者_运维技巧.bs.add(b1);
 a2.bs.add(b2);
 //end trasaction
}catch{
  //rollback
}

What is the best way to do it?


Inside your transaction, you will have to iterate through your bs collections and put each object to the datastore.

One thing to keep in mind is that GAE transactions operate on entities in the same entity group. I would suggest taking a look at the documentation if you haven't already done so.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号