Java Reference
In-Depth Information
Table 23-1: Comparison of Major Persistence Mechanisms
Serialization
JDBC
EJB
JDO
Transparent
Persistence
Transparent
Not transparent
Session and BMP
entity bean is not
transparent. CMP EJB
is partially transparent.
Transparent
Domain Object
Model
Fully object
oriented.
Inherently not
object oriented.
Simple domain object
model. No inheritance.
Fully object
oriented.
Support
complex
domain
object model.
Query
Not
supported
Supported by
writing SQL
code.
Supported by
declarative query by
CMP entity beans, and
SQL code by session
and BMP entity beans.
Extended
support via
JDO QL
Transaction
Not surported
Supported
Supported
Supported
Database
Portability
N/A
Weak support
for relational
DBs. May have
to recode due
to SQL variant.
Do not suport
OO and XML
DBs.
Session and BMP
entity bean has same
level of support as
JDBC. CMP entity
bean has better
support.
Good support
- "write once,
persist
everywhere"
Major JDO APIs
Compared with other Java technologies, JDO has a set of very simple APIs. The package javax.jdo
contains 12 interfaces, five classes and nine exceptions. These interfaces and classes are all you need
when you develop Java classes whose instances are to be stored in persistence stores. These APIs
specify the contracts between your persistent-capable classes and the runtime environment that is part
of the JDO implementation. The JDO implementation is provided by JDO vendors, and there are
currently quite a few implementations available on the market. A set of contracts between application
developers and JDO vendors is defined in the JDO architecture and specified through these APIs.
The following sections discuss these interfaces:
 
PersistenceCapable
 
PersistenceManagerFactory
 
PersistenceManager
 
Query
 
Transaction
PersistenceCapable Interface
The javax.jdo.PersistenceCapable interface makes a Java class capable of being persisted by
a persistence manager through a JDO implementation. Every class whose instances can be managed
by a JDO PersistenceManager must implement the PersistenceCapable interface.
This interface defines methods that allow the implementation to manage the instances. It also defines
methods that allow a JDO-aware application to examine the runtime state of instances. For example, an
application can discover whether the instance is persistent, transactional, dirty, new, or deleted and can
get its associated PersistenceManager if it has one.
Search WWH ::




Custom Search