开发者

Updating multiple entities in google appengine

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜