[ Team LiB ] |
Chapter 8. Instance ManagementYour 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 is null, a transient instance of a persistent class, or an instance of a transient (nonpersistent) class. This chapter describes how to make instances persistent, access them via an extent, navigate among persistent instances, modify their state, and delete instances from the datastore. These are referred to as the CRUD operations of using a database: Create, Read, Update, and Delete. Chapter 13 covers advanced operations for managing instances. |
[ Team LiB ] |