views:

73

answers:

2

I had following error from Google App Engine when I was trying to iterate list in JSP page with EL.

Object Manager has been closed

I solved problem with following code, but I don't think that it is very good solution to this problem:

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;
    }

When I tried to use pm.detachCopyAll(items) it gave same error. I understood that detachCopyAll() method should do same what I did, but that method should be part of data nucelus, so it should be used instead of my owm methods. So why dosen't detachCopyAll() work at all?

A: 

I solved this myself. I didn't had @PersistenceCapable(detachable="true") at my entity, so apparently objects aren't detachable by deafult.

@PersistenceCapable(detachable="true")
public class Item {

...

}
newbie
A: 

the solution that work for i found here:

http://groups.google.com/group/google-appengine-java/browse_thread/thread/945f6ca66c1c587e

alexis