3.2 The JDO Basics


The JDO specification defines 20 or so classes and interfaces in total, but a developer needs to know only five main classes (which are actually Java interfaces):

  • PersistenceManagerFactory

  • PersistenceManager

  • Extent

  • Query

  • Transaction

Figure 3-3 provides a simplified class diagram showing how these interfaces are related :

Figure 3-3. A simplified JDO class diagram.

graphics/03fig03.gif

A PersistenceManagerFactory is used to get a PersistenceManager instance. There is a one-to-many relationship between the PersistenceManagerFactory and the PersistenceManager. A PersistenceManagerFactory can create and manage many PersistenceManager instances and even implement pooling of PersistenceManager instances.

A PersistenceManager embodies a connection to a datastore and a cache of in-memory persistent objects. The PersistenceManager interface is the primary means by which the application interacts with the underlying datastore and in-memory persistent objects.

From a PersistenceManager, the application can get one or more Query instances. A Query is how the application can find a persistent object by its field values.

In addition to a Query, the application can get an Extent from a PersistenceManager. An Extent represents all the instances of a specified class (and optionally subclasses) stored in the datastore and can be used as input to a Query or iterated through in its own right.

A Transaction allows the application to control the transaction boundaries in the underlying datastore. There is a one-to-one correlation between a Transaction and a PersistenceManager; there can be only one ongoing transaction per PersistenceManager instance. Transactions must be explicitly started, and either committed or aborted.



Core Java Data Objects
Core Java Data Objects
ISBN: 0131407317
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net