views:

183

answers:

1

What is the preferred way of using GAE datastore PersistenceManager for web app? GAE instructions are a bit ambiguous on the matter.

Do I instantiate PersistenceManagerFactory for each RPC call, or do I use only one factory for all requests? Do I call PMF.get().getPersistenceManager(), or do I call PMF.get().getPersistenceManagerProxy()? Do I close PM after each RPC call, or do I leave it open? What are you guys doing?

Furthermore, I'm not certain how GAE handles 30-second-per-request limit. Is it even possible to reference the same PM between requests?

+4  A: 

A PMF is expensive to create, hence only one per app makes sense. And getting a PM per request also makes sense since not expensive. Really depends what you're planning on doing with the objects between requests, whether you want to detach them, and then reattach on a subsequent request.

GAE/J app recycling obviously causes a new PMF hence a delay, something that is for Google to address; there's a thread on their forum that looked at timings of initialisation of various things and I suggested what they could do but its for them to put resource into that effort.

HTH

DataNucleus