Acquiring a PersistenceManager

Once you have configured a PersistenceManagerFactory with the appropriate property settings, you can call one of the following PersistenceManagerFactory methods to construct a PersistenceManager instance:

PersistenceManager getPersistenceManager(  );
PersistenceManager getPersistenceManager(String userid, String password);

The returned instance may come from a pool of PersistenceManager instances, but the property values in the returned PersistenceManager instance are equal to their values in the PersistenceManagerFactory instance.

After your first call to getPersistenceManager( ), none of the set methods in the PersistenceManagerFactory will succeed. You may be able to modify the setting of operational parameters dynamically using a vendor-specific interface.

If you acquire the PersistenceManager by calling the getPersistenceManager( ) method that has the userid and password parameters, all of the manager’s accesses to get a connection from the connection factory use the provided userid and password. If PersistenceManager instances are pooled, then getPersistenceManager( ) returns only a PersistenceManager instance with the same userid and password.

You may need to access the PersistenceManagerFactory that was used to create a PersistenceManager. You can call the following PersistenceManager method to access it:

PersistenceManagerFactory  getPersistenceManagerFactory(  );

If a PersistenceManagerFactory instance was not used to create the PersistenceManager ...

Get Java Data Objects now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.