-1
我收到以下错误:javax.jdo.JDODetachedFieldAccessException JDO的App Engine
javax.jdo.JDODetachedFieldAccessException:您刚才试图访问领域的“管理员”然而,当你脱离的对象完全没有剥离,这个领域。要么不访问此字段,要么在分离对象时将其分离。
这里我有一个具有管理员领域的一个子类存储对象的列表。
我第一次调用这个函数
static List<Store> getStores() {
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(XZStore.class);
List<Store> stores = (List<Store>) query.execute();
//need to detatch them here
stores = (List<Store>) pm.detachCopyAll(stores);
pm.close();
return stores;
}
,然后访问该商店的管理领域(store.admin)中的每一个。
我想如果我detachCopyAll(存储),那么我也detatch存储的 元素的成员。不是吗?
我甚至尝试以下,但没有运气:
for (Store store : stores)
store.setAdmin(pm.detachCopy(store.getAdmin()));
感谢,
约翰Goche的
我终于找到了解决办法。以下为我工作 (分离容器元素未剥离的成员 元素,我不得不分开做)。
PersistenceManager pm = PMF.get().getPersistenceManager();
Query query = pm.newQuery(Store.class);
List<Store> stores = (List<Store>) query.execute();
//need to detatch them here
List<Store> detachedStores = new ArrayList<Store>();
for (Store store : stores) {
Store detachedStore = pm.detachCopy(store);
AdminUser detachedAdmin = pm.detachCopy(store.getAdmin());
detachedStore.setAdmin(detachedAdmin);
detachedStores.add(detachedStore);
}
pm.close();
问候,
约翰Goche的
好,分离在不同的实体组的实体之前,我想获得这个简单的例子,如果在所有可能的第一份工作......,尤其是当我需要分离的东西,使之成为持久的,如果我需要访问后的任何时间它又是什么? – johngoche9999 2012-01-28 23:25:37
默认获取组不让我获取多值属性。 – johngoche9999 2012-01-29 13:48:01