[GAE] 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)

Thecode 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();//加上这个就行了,和hibernate的懒加载很像
    pm.close();
    return customers;
}

<script type="text/javascript"></script>

你可能感兴趣的:(JavaScript,Hibernate,Google,GAE)