Java Reference
In-Depth Information
the ORM framework. Also, the database schema is often owned and maintained by
a separate group, such as the DBA s.
4.3.2
API for creating, reading, updating, and deleting objects
The Hibernate and JDO API s are quite similar and consist of interfaces that play
the following roles:
A connection factory interface for creating connections
A connection interface, which represents a connection to the database and
provides methods for creating, loading, and deleting persistent objects
A query interface for executing queries
A transaction interface for managing transactions
Table 4.1 shows the interfaces provided by Hibernate and JDO that play these
roles.
Table 4.1
The key JDO and Hibernate interfaces
Role
JDO
Hibernate
Connection factory
PersistenceManagerFactory
SessionFactory
Connection
PersistenceManager
Session
Query
Query
Query
Transaction
Transaction
Transaction
The repositories in the example application call the connection and query inter-
faces to create, find, and delete persistence objects. The POJO façade calls the
connection factory to create a connection, the transaction interface to manage
transactions, and the connection interface to detach and attach objects.
In chapters 5 and 6 we will see that the business tier typically uses a single con-
nection while handling a request from the presentation tier. It creates a connection
at the start of each request and closes the connection at the end of handling the
request. A Hibernate application creates a Session by calling SessionFactory
.openSession() , and a JDO application creates a PersistenceManager by calling Per-
sistenceManagerFactory.makePersistenceManager() . The application can then
use Session or PersistenceManager to create, load, or delete objects; create a query;
and access the transaction interface.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search