Message from discussion
NucleusUserException: Object Manager has been closed
MIME-Version: 1.0
Received: by 10.100.9.19 with SMTP id 19mr270418ani.24.1239631277119; Mon, 13
Apr 2009 07:01:17 -0700 (PDT)
Date: Mon, 13 Apr 2009 07:01:17 -0700 (PDT)
X-IP: 58.186.227.93
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8)
Gecko/2009032609 Firefox/3.0.8 GTB5 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
Message-ID: <b4aefed0-2c2a-4dc7-91bf-3f0f13e98670@x1g2000prh.googlegroups.com>
Subject: NucleusUserException: Object Manager has been closed
From: tha <hathanht...@gmail.com>
To: Google App Engine for Java <google-appengine-java@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi all,
Today I got this error "NucleusUserException: Object Manager has been
closed" in my Spring application. Basically, my application loads some
objects in DAO classes, close the transaction (using Spring declared
transactions) and returns the result to View layer. But when I access
the objects' properties, I got the error. After looking at the
GetFlights.java file (helloorm demo, GAE SDK), I see that the size()
method must be called before closing the transaction. So I changed my
DAO method to:
public List<T> findAll() {
List<T> results = entityManager.createQuery("select o from "
+ getPersistentClass().getName() + " o").getResultList();
results.size(); // In JPA apps, we don't need this call!!
return results;
}
It is working now. But I don't like the idea to call the size()
method. In theory, a JPA application must work with any JPA-compliant
provider. And a JPA application doesn't call size() method just to
load the results from query. So I believe that (DataNucleaus +
appengine plugin) is not a JPA-compliant provider. Please correct me
if I'm wrong.