`

GAE Exception: Object Manager has been closed

阅读更多

Root cause:
org.datanucleus.exceptions.NucleusUserException: Object Manager has been closed

Are you using Google App Engine for java and JDO?
If you ask for a list of something you might have to call the method size(). (studip i know)

The code below would throw org.datanucleus.exceptions.NucleusUserException: "Object Manager has been closed" if we removed the call to size()

public List<Customer>getAllCustomers()
{
    List<Customer> customers = new ArrayList();
    PersistenceManager pm = pmfInstance.getPersistenceManager();
    String query = "select from " + Customer.class.getName();
    customers = (List<Customer> pm.newQuery(query).execute();
    customers.size();
    pm.close();
    return customers;
}

分享到:
评论
4 楼 xredman 2010-10-11  
jumkey 写道
能不能解释一下原因

个人觉得是lazy-load之类的东西
3 楼 jumkey 2010-06-03  
xiebaolong 写道
这问题都搞了我两天了,也没想出是怎么回事,这是为什么呀?

要pm.detachCopyAll(customers)才行
单个对象pm.detachCopy(customer);
2 楼 xiebaolong 2010-05-26  
这问题都搞了我两天了,也没想出是怎么回事,这是为什么呀?
1 楼 jumkey 2010-05-11  
能不能解释一下原因

相关推荐

Global site tag (gtag.js) - Google Analytics