开发者

slim3 distributed transaction on appengine

from example

@Model
publ开发者_JAVA百科ic class Account {

    @Attribute(primaryKey = true)
    private Key key;

    private Integer balance;
    ...
}

from example http://sites.google.com/site/slim3appengine/ i do not understand why doing money transfer need 2 different transaction as this is only one entity (same entity)

  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 and dest are different entities - you're fetching them with separate keys (srcKey and destKey).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜