2010-12-09 57 views

回答

2

是的,尽管不像您期待的那么平常。

限制

  1. 请问time out if it takes more then 30 seconds, 除非你运行它作为任务,在这种情况下, 它会time out if it takes more then 10 minutes
  2. 有没有更智能的方法来获得 您需要更新的实体 您can't query on a property that doesn't exist

解决办法

  1. 你要考虑的 appengine-mapreduce project到 得到实现,可 完成更多的则10分钟 挂钟时间。
  2. 未知。

代码

void updateNullBarField() { 
    final Text DEFAULT_BAR = new Text("bar"); 

    PersistenceManagerFactory pmfInstance = JDOHelper 
    .getPersistenceManagerFactory("transactions-optional"); 
    PersistenceManager pm = pmfInstance.getPersistenceManager(); 
    Query query = pm.newQuery(Foo.class); 
    @SuppressWarnings("unchecked") 
    Collection<Foo> foos = pm.detachCopyAll((List<Foo>) query.execute()); 

    for (Foo foo : foos) { 
    if (foo.bar == null) { 
     foo.bar = DEFAULT_BAR; 
     pm.detachCopy(pm.makePersistent(foo)); 
    } 
    } 
} 
相关问题