DekGenius.com
[ Team LiB ] Previous Section Next Section

7.4 Multiple PersistenceManagers

A PersistenceManager supports one transaction and uses one connection to the underlying datastore at a time. A PersistenceManager might use multiple transactions serially, and it might use multiple connections in the datastore serially.

But you may want to perform multiple transactions concurrently. You can do this by instantiating multiple PersistenceManager instances. Each will have its own Transaction instance. Each call to PersistenceManagerFactory.getPersistenceManager( ) returns a new PersistenceManager instance. Each persistent instance in the JVM is associated with a single PersistenceManager. Multiple PersistenceManager instances may have their own separate copy of the same datastore instance. A common application-programming technique is to have a separate thread or thread group for each PersistenceManager that is managing a set of instances.

You can also use multiple PersistenceManager instances from different JDO implementations in the same JVM. This is how things operate in an application-server environment, where each active session has its own transaction. Each active session has its own PersistenceManager instance. Because of JDO's binary compatibility capabilities, these PersistenceManager instances can manipulate instances of the same persistent classes.

    [ Team LiB ] Previous Section Next Section