【发布时间】:2010-06-03 18:52:36
【问题描述】:
当我尝试使用 EL 迭代 JSP 页面中的列表时,我遇到了来自 Google App Engine 的以下错误。
Object Manager has been closed
我用下面的代码解决了问题,但我认为这不是解决这个问题的好方法:
public List<Item> getItems() {
PersistenceManager pm = getPersistenceManager();
Query query = pm.newQuery("select from " + Item.class.getName());
List<Item> items = (List<Items>) query.execute();
List<Item> items2 = new ArrayList<Item>(); // This line solved my problem
Collections.copy(items, items2); // and this also
pm.close();
return (List<Item>) items;
}
当我尝试使用 pm.detachCopyAll(items) 时,它给出了同样的错误。我知道 detachCopyAll() 方法应该和我做的一样,但是该方法应该是数据核心的一部分,所以应该使用它而不是我的 owm 方法。那么为什么 detachCopyAll() 根本不起作用呢?
【问题讨论】: