2011年8月25日木曜日

slim3を触ってみる(写経編-その4)

http://www.seattleconsulting.co.jp/gae/slim3_dev_for_beginner_index.html
の写経記録

CRUD操作まで終わり。
明日はコメント部分の構築。

CRUD操作で詰まったところ。

例文はこうなってた。
Transaction tx = Datastore.beginTransaction();
    try {
        Datastore.put(tx, head, body);
        Datastore.commit(tx);
    }
    catch (Exception e) {
        if (tx.isActive()) {
            Datastore.rollback(tx);
        }
        throw e;
    }

どうしてもcommitとrollbackでワーニングが出るのが気になって
こう書き直した。

         Transaction tx = Datastore.beginTransaction();
        
        try{
                Datastore.put(tx,head,body);
                tx.commit();
        } catch (Exception e) {
            if (tx.isActive()) {
                tx.rollback();
            }
            throw e;
        }

はたして動くのだろうか。

0 件のコメント:

コメントを投稿