0

例から

@Model
public class Account {

    @Attribute(primaryKey = true)
    private Key key;

    private Integer balance;
    ...
}

例からhttp://sites.google.com/site/slim3appengine/ これは1つのエンティティ(同じエンティティ)にすぎないため、送金を行うのに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);
    }
4

1 に答える 1

1

src と dest は異なるエンティティです。別々のキー (srcKey と destKey) でフェッチしています。

于 2010-12-13T05:12:07.580 に答える