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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.