Chapter 3: The Persistence Manage


Overview

Chapter 1 Describes, in general terms, the implicit and explicit persistence services that JDO provides. The application does not take any special steps to invoke the implicit services. JDO provides them automatically and transparently to all objects whose classes implement the PersistenceCapable interface. On the other hand, to invoke the explicit services, the application calls the JDO API at the appropriate points in its code. Most of the explicit persistence services are contained in the PersistenceManager interface. Those related to transactions are found in the Transaction interface. This chapter discusses the PersistenceManager interface. Chapter 4 describes the Transaction interface.

The persistence manager acts on application data objects. As a result of enhancement, the application data classes implement the PersistenceCapable interface. Passing an object that does not implement the PersistenceCapable interface to a method in the persistence manager will likely cause a ClassCastException. In all cases, the persistence manager performs useful actions only on application data objects.

If the object passed to a persistence manager's operation is controlled by a different persistence manager, the operation throws a JDOUserException.

Figure 3-1 presents the UML class diagram for the PersistenceManager interface. This is the largest class diagram in JDO, with five groups of operations and five properties. This chapter examines the methods that define the operations and the properties.

click to expand
Figure 3-1: The class diagram of the PersistenceManager interface

As Figure 3-1 indicates, there are five groups of operations in the PersistenceManager interface. Because the JDO implementations can, and usually will, implement pooling of persistence managers and the datastore connections that they use, it is efficient for applications to frequently obtain and close persistence managers. Using a persistence manager, the application can control the life cycle and caching of application data objects. It can get the identity object for a persistent application data object, and it can later fetch the persistent object that corresponds to an identity object. Finally, the PersistenceManager interface has factory methods that return Query, Extent, and Transaction objects.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

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