This is really up to you, though I would avoid detaching unless absolutely
necessary. Opening and closing a PersistenceManager should be extremely
cheap (it's instantiating a PersistenceManagerFactory that's expensive).
You've got a few options here, and what you do really just depends on what
makes sense for you:

- dependency inject the PersistenceManager into a DAO class that you
instantiate and pass that instance around, closing it when you are complete
- open and close each time in the DAO - the problem here is if you need a
PersistenceManager that spans DAO objects (either build that into a method
or a Service layer, though for the record I have an aversion to additional,
unnecessary layers that do a single thing)

>From a performance perspective, we aren't doing anything. If you take a look
at the low-level API documentation, there's no concept of "close":

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/package-summary.html

On Wed, Feb 10, 2010 at 8:26 AM, hsjawanda <hsjawa...@gmail.com> wrote:

> Nobody knows the answer to this?
>
> On Feb 7, 2:34 pm, hsjawanda <hsjawa...@gmail.com> wrote:
> > Should the PersistenceManager be closed after every query?
> >
> > I have a utility class that handles querying the datastore. This class
> > then returns results which are used by JSP pages to show output.
> >
> > AFAIK, these are my options:
> >
> > * Make all my data objects detachable (what is the extra cost of doing
> > this? Don't they have to be copied when detaching?
> > )
> > * Make a second call on the utility class to close the PM (defeats the
> > purpose of having the utility class)
> >
> > * Leave my PM unclosed (what is/are the implications of this?)
> >
> > I am referring to a case where I am only doing reads from the data
> > store.
> >
> > Regards,
> > Harshdeep
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
http://googleappengine.blogspot.com | http://twitter.com/app_engine

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to