Chapter 7. Establishing a JDO Runtime Environment

This chapter describes how to establish a JDO runtime environment. This includes specifying the particular JDO implementation to be used, connecting to the datastore, and setting various properties that control the management of transactions and the cache of persistent instances.

Your primary interface when using JDO is the PersistenceManager interface. You configure a PersistenceManager instance by using a PersistenceManagerFactory instance, which you can create by calling a method defined in JDOHelper. Or, in a Java 2 Platform, Enterprise Edition (J2EE) environment, you would likely use Java Naming and Directory Interface (JNDI) to store and look up one or more PersistenceManagerFactory instances.

You can initialize and set various properties within the PersistenceManagerFactory, including the information needed to connect to the datastore. Once you have established the desired configuration, you call a PersistenceManagerFactory method to create a PersistenceManager instance. You can create multiple PersistenceManagers from a single PersistenceManagerFactory, and you can alter some of the properties in a PersistenceManager once it has been created.

A PersistenceManager instance has a one-to-one relationship with an associated Transaction instance. The PersistenceManager interface provides a method to access this instance. The property settings in the PersistenceManager and Transaction instances control the runtime behavior of the JDO runtime environment.

Figure 7-1 illustrates the relationships among these classes and the methods you can use to access and create the associated instances. This chapter describes the capabilities these interfaces provide, so you can configure your application's runtime environment for accessing the datastore.

Figure 7-1. Interfaces used to configure and control the JDO runtime environment