Java Reference
In-Depth Information
PersistentenceManagerFactory pmf = (PersistenceManagerFactory) ctx.lookup(
"java:comp/env/jdo/JNDI_NAME_FOR_YOUR_PMF");
PersistenceManager pm = pmf.getPersistenceManager();
Most JDO-implementation vendors provide some proprietary APIs to instantiate instances of
PersistenceManagerFactory by other means such as properties.
PersistenceManager Interface
The javax.jdo.PersistenceManager interface is the primary one for JDO-aware application
components. It is the factory for Query and Transaction instances and contains methods to manage
the life cycle of PersistenceCapable instances. The most commonly used methods include the
following:
 
Make instances persistent
 
void makePersistent(Object pc)
 
void makePersistentAll(Object[] pcs)
 
void makePersistentAll(Collection pcs)
 
Delete persistent instances
 
void deletePersistent(Object pc)
 
void deletePersistentAll(Object[] pcs)
 
void deletePersistentAll(Collection pcs)
 
Make instance transient — disassociate the instance from the persistence manager. The data
stored in the data store is not deleted.
 
void makeTransient(Object pc)
 
void makeTransientAll(Object[] pcs)
 
void makeTransientAll(Collection pcs)
 
Handle persisted object IDs
 
Object GetObjectId(Object pc)
 
Object getObjectById(Object oid, boolean validate)
 
Give access to current transaction interface
 
Transaction currentTransaction()
 
Serve as the factory for the Query Interface
 
Query newQuery()
 
Query newQuery(java.lang.Class cls)
 
Query newQuery(A variety of parameters can be passed in)
The usage of some of these APIs is seen from the example test client of the Yacht class listed later in
this chapter under " A Test Client Example ."
A JDO PersistenceManager instance supports one transaction at a time and uses one connection to
the underlying data source at a time. The JDO PersistenceManager instance might use multiple
transactions serially and might use multiple connections serially.
Normally, cache management is automatic and transparent. When instances are queried, navigated to,
or modified, instantiation of instances and their fields and garbage collection of unreferenced instances
occur without any explicit control. When the transaction commits in which persistent instances are
created, deleted, or modified, eviction is automatically handled by the transaction-completion
mechanisms.
Query Interface
The javax.jdo.Query interface allows applications to obtain persistent instances from the data store.
The PersistenceManager is the factory for Query instances. There may be many Query instances
associated with a PersistenceManager . Multiple queries might be executed simultaneously by
Search WWH ::




Custom Search