Presented by developerWorks, your source for great tutorials
Section 1. Introduction
Introduction to CMP/CMR
This tutorial is designed to introduce you to Container Managed Persistence (CMP)
and Container Managed Relationships (CMR) in Enterprise JavaBeans 2.0 (EJB).
These features are particular to EJB entity beans that are typically long lived as
compared to session beans that are normally transitory.
Enterprise JavaBeans (EJB) 2.0 extends the earlier version 1.1 by adding advanced
support for entity beans as follows:
updated container managed persistence for entity beans
support for container managed relationships
EJB Query Language (EJB QL) for portable
query methods defined
in the deployment descriptor
The addition of local interfaces and local home interfaces to optimize access from
other beans in the same container.
If you want to buy or sell components, you will most likely want a layer of persistence in
your components to work cross platform on application servers (for example, IBM
WebSphere, BEA WebLogic, JBoss/Tomcat, etc.) and persistence storage systems (for
example, Oracle, DB2, etc.). You do not have to write low level Java Database
Connectivity (JDBC) calls in your EJBs to add these features, a great reducer of time
and complexity. Once you get the hang of CMP/CMR, it is faster to write entity beans
using this technology, than using low level JDBC inside of bean managed persistence
Should I care about CMP/CMR?
What does this mean to you? Well, for starters, you do not have to write low level
JDBC calls and, you do not have to write code to manage relationships. It is all built
into the EJB framework. Your interface to relationships is through the pervasive
which most EJB developers are
already familiar with. Very cool!
This additional feature includes support for JavaBeans component patterns for
persistent fields, inside of the entity bean. Thus, instead of making your class variables
public which has always felt strange to me you create get and set methods
following the JavaBean s standard naming pattern we all know and love.
Page 2 of 48
Introducing EJB CMP/CMR, Part 1 of 2