Java Reference
In-Depth Information
Declarative mapping between the object model and database schema —Describes
how the object model's classes, attributes and relationships are mapped to
database table and columns and used by the ORM framework to generate
SQL statements
An API for creating, reading, updating, and deleting objects —Called by the
domain model's repositories to manipulate persistent data
A query language —Used to efficiently find persistent objects that satisfy
search criteria
Support for transactions —Maintains data integrity and handles concurrent
updates
Lazy and eager loading —Optimizes performance by controlling when objects
are loaded
Caching —Improves performance by minimizing database accesses
Detached objects —Enables persistent objects to be passed between the presen-
tation tier and the business tier
Before looking at these features in detail, let's first see how an ORM framework fits
in with the rest of the application. Figure 4.3 shows that the framework is invoked
by the POJO façade and the repositories.
The POJO façade calls the ORM framework to manage transactions and detach
and attach objects. The repositories call it to create, find, and delete persistent
objects such as PendingOrder and Restaurant . The framework accesses the data-
base using SQL statements generated from the declarative mapping information.
Let's now look at each of main features of an ORM framework.
Declarative mapping between the object model and schema
An ORM framework lets you specify how your domain model maps to your data-
base schema using the mapping options described earlier in section 4.1. You typi-
cally define the mapping using XML , although some O/R frameworks also allow
you to use Java 5 annotations. The mapping document or annotations specify how
classes map to tables, how fields or JavaBean properties map to columns, and how
relationships map to foreign keys or join tables. The ORM framework uses this
mapping information to generate the SQL statements that load, save, update, and
delete persistent objects.
The ORM framework provides transparent persistence. The persistent classes
are rarely aware that they are persistent. Quite often you only need to add a field
that stores the persistent identity. They do not have to implement any special
 
 
 
Search WWH ::




Custom Search