Chapter 8. Instance Management

Your object model is usually composed of a set of classes with many interrelationships. The graph of all the related instances of those classes may include the entire contents of the datastore, but typically your applications deal with only a small number of the persistent instances at a time. JDO provides the illusion that your application can access the entire graph of connected instances, while in reality it only instantiates the small subset of instances that the application needs. This concept is called transparent data access , transparent persistence , or simply transparency .

A PersistenceManager manages the persistent instances accessed from a datastore. It provides methods to make instances persistent and to delete instances from the datastore. It also provides factory methods to construct Extent and Query instances, which you use to access instances from the datastore.

A PersistenceManager can manage any number of persistent instances at a time. Each instance of a persistent class is associated with one PersistenceManager or zero PersistenceManagers. A transient instance is not associated with any PersistenceManager instance. As soon as an instance is made persistent or transactional, it is associated with exactly one PersistenceManager.

You can use a static JDOHelper method to access the PersistenceManager associated with a persistent instance:

static PersistenceManager getPersistenceManager(Object obj);

It returns null if the obj parameter ...

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.