JDO : PersistenceManager Proxies

As you read in the guide for PersistenceManager, you perform all operations using a PersistenceManager. This means that you need to obtain this when you want to start datastore operations. In some architectures (e.g in a web environment) it can be convenient to maintain a single PersistenceManager for use in a servlet init() method to initialise a static variable. Alternatively for use in a SessionBean to initialise a static variable. Thereafter you just refer to the proxy. The proxy isn't the actual PersistenceManager just a proxy, delegating to the real object. If you call close() on the proxy the real PM will be closed, and when you next invoke an operation on the proxy it will create a new PM delegate and work with that.

To create a PM proxy is simple

PersistenceManager pm = pmf.getPersistenceManagerProxy();

So we have our proxy, and now we can perform operations