surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

Object manager closed | Strust 2| GAE #186

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi All,

 I have configured in Struts2 in google app engine and use the JDO 
concepts. when i tried to fetch data using JDO concepts,i got error object 
manager is closed. Please see the my foolowing code :

public List<Customer> getCustomerList(String query) {
  PersistenceManager pm = PMF.get().getPersistenceManager();
   try {
    customerlist = (List<Customer>)pm.newQuery(query).execute();
    } finally {
    pm.close();
    }
       return customerlist;
 }

through Struts i call the above method, it is working fine but when am 
tried to iterate this list ,i got an error is object manager is closed. 
please seee the my struts code..

 private List<Customer> customerlist; 
 public String execute() {
  // insert code
     Customer customer=new Customer(getName(),getMailaddress(),new Date());
        customerservice=new CustomerServiceImpl();
        this.customerservice.insert(customer);

  // get customer list code
      String query = "select from " + Customer.class.getName();   
      this.customerlist=this.customerservice.getCustomerList(query);
       if (customerlist.isEmpty()) {
    }else{
      for (Customer g : customerlist) {
        System.out.println("employee name------>"+g.getMailaddress());
            }
    }

}

Please help me...

how to solve these issues.

Regards,
Siva K

Original issue reported on code.google.com by siva.ka...@gmail.com on 9 Jan 2010 at 6:58

GoogleCodeExporter commented 8 years ago
A lot of people is getting the same problem.  Call size() method before close 
your EntityManager. 

I think this is a bug.
http://stackoverflow.com/questions/2968868/google-app-engine-error-object-manage
r-has-been-closed/4879775#4879775

Original comment by eduardop...@gmail.com on 2 Feb 2011 at 8:57

GoogleCodeExporter commented 8 years ago
SVN trunk doesn't have this problem (i.e the close of the PM informs the query 
of the connection imminent closure and all records are read in

Original comment by googleco...@yahoo.co.uk on 15 Jul 2011 at 1:02