Thank you Amy for your reply...
On Mon, Jan 30, 2012 at 12:41 AM, Amy Unruh amyu+gro...@google.com wrote:
A pointer to the related Stack Overflow question, where I've provided *an*
answer, related to needing to fetch child objects before closing the
PersistenceManager:
http://stackoverflow.com/questions/9049491/org-datanucleus-exceptions-nucleususerexception-object-manager-has-been-closed/
I have tried touching everything as follows, but I still get an exception
when I try accessing the data.
static XZStore getStoreByEmail(String email) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
ExtentXZStore storeExtent = pm.getExtent(XZStore.class);
for (XZStore store : storeExtent) {
if (store.getAdmin().getEmail().equals(email)) {
XZStore detachedStore = pm.detachCopy(store);
detachedStore.setAdmin(pm.detachCopy(store.getAdmin()));
detachedStore.setUsers((ListUser)
pm.detachCopyAll((store.getUsers(;
detachedStore.setInventory((ListItem)
pm.detachCopyAll(store.getInventory()));
detachedStore.setReceipts((ListReceipt)
pm.detachCopyAll(store.getReceipts()));
ListSale detachedSales = new ArrayListSale();
for (Sale sale : store.getSales()) {
Sale detachedSale = pm.detachCopy(sale);
detachedSale.setSaleItems((ListSaleItem)
pm.detachCopyAll(sale.getSaleItems()));
detachedSales.add(detachedSale);
}
detachedStore.setSales(detachedSales);
detachedStore.setShipments((ListShipment)
pm.detachCopyAll(store.getShipments()));
detachedStore.setCustomers((ListCustomer)
pm.detachCopyAll(store.getCustomers()));
detachedStore.setCompany(pm.detachCopy(store.getCompany()));
storeExtent.closeAll();
return detachedStore;
}
}
storeExtent.closeAll();
return null;
} finally {
pm.close();
}
}
Though, I see that you're not sure whether this is the issue you're
running into. You might do a test in which you explicitly fetch the data
from every field you'll need to later access in the detatched objects,
while you're still in the open PersistenceManager context, and see if this
fixes the problem.
As you can see I've tried it but it does not fix the problem, unless I also
have to access the simple fields such as String, Data, int, long, double,
etc... which should
have been retrieved automatically I suppose since they are not lists?
Thanks,
JG
On Sun, Jan 29, 2012 at 10:52 AM, John Goche
johngoch...@googlemail.comwrote:
Hello,
If anyone knows how to deal with
org.datanucleus.exceptions.NucleusUserException: Object Manager has been
closed
any help would be greatly appreciated. Here is the code which is throwing
the exception:
static void persistStore() {
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
pm.makePersistent(Data.store);
tx.commit();
} finally {
if (tx.isActive())
tx.rollback();
pm.close();
}
}
I don't see anything wrong with the code. Any ideas?
John Goche
--
You received this message because you are subscribed to the Google Groups
Google App Engine for Java group.
To post to this group, send email to
google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.
--
You received this message because you are subscribed to the Google Groups
Google App Engine for Java group.
To post to this group, send email to
google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.
--
You received this message because you are subscribed to the Google Groups
Google App Engine for Java group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.