开发者

slim3 distributed transaction on appengine

开发者 https://www.devze.com 2023-01-30 10:08 出处:网络
from example @Model publ开发者_JAVA百科ic class Account { @Attribute(primaryKey = true) private Key key;

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

精彩评论

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