slim3从例如http://sites.google.com/site/slim3appengine/ AppEngine上
问题描述:
@Model
public class Account {
@Attribute(primaryKey = true)
private Key key;
private Integer balance;
...
}
我不明白为什么这样做汇款需要2个不同的交易,因为这是唯一的一个实体(同一实体)
Acount src = gtx.get(Acount.class, srcKey); //arent src and des same entity? why do 2 trans?
Acount dest = gtx.get(Acount.class, destKey);
if (src.getBalance() >= amount) {
src.setBalance(src.getBalance() - amount);
dest.setBalance(dest.getBalance() + amount);
}
答
src和dest是不同的实体 - 你用单独的键(srcKey和destKey)来获取它们。
是独立的实体,我同意。但都使用相同的实体组。所以不能在一个周期内完成交易?而不是2? – cometta 2010-12-14 04:09:12
@cometta他们不在同一个实体组中。实体组是具有相同父代的实体,并且上述两个实体都是根实体,没有父母。 – 2010-12-14 22:53:52