2015-04-07 54 views
-1

我使用的是GAE Object mapping framework(和內置我們的應用程序在其周圍),此代碼工作無法獲得實體走出數據存儲的主要

Key key = put(thing); 
Thing thing = get(Thing.class, key); 

上面代碼的偉大工程。

現在,有這種putInTransaction方法:

@Override 
public Key putInTransaction(Object object) { 
    Transaction tx = _ds.beginTransaction(_options); 
    Key result = null; 
    try { 
     result = put(object); 
    } catch (Exception e) { 
     e.printStackTrace(); 
     tx.rollback(); 
    } finally { 
     if (tx.isActive()) { 
      tx.rollback(); 
     } 
    } 
    return result; 
} 

其中我比較從put(thing)putInTransaction(thing)碼鍵和具有相同kindidnameappIdNamespace

的同一數據存儲 Key

現在的問題是,當使用密鑰get(Thing.class,key)putInTranscation(thing)進行JUnit測試時,它不會返回實體w hile當測試與put(thing)它工作正常。 這裏有什麼問題?

+1

我沒有看到你在任何地方提交交易?! – koma

+0

哇很好。 – xybrek

回答

0

答案是需要添加的代碼中缺少數據存儲事務提交。

相關問題