user manual
Chapter 15: Entity Beans and Table Mapping for CMP 2.0 153
Container-Managed Persistence in Borland Enterprise Server
editing is also managed by the PM. This simplifies interactions with the
container and allows the PM to optimize its read and write operations. This
approach also suppresses duplicate find requests by tracking returned
primary keys for requested entities. Data from duplicate find operations can
then be returned from the first load of the entity's data.
Borland CMP engine's CMP 2.0 implementation
In CMP 2.0, the details of constructing finder and select methods have been
pushed into the EJB 2.0 specification. Users should thoroughly inspect the
specification for details on implementing their database SQL. The Borland
EJB Container is fully-compliant with the EJB 2.0 specification and supports all
of its features.
The implementation class for an entity bean using 2.0 container-managed
persistence is different from that of a bean using 1.1 container-managed
persistence. The major differences are as follows:
■
The class is declared as an abstract class.
■
There are no public declarations for the fields that are container-managed
fields. Instead, there are abstract get and set methods for container-
managed fields. These methods are abstract because the container
provides their implementation. For example, rather than declaring the fields
balance and name, the CheckingAccount class might include these get and set
methods:
public abstract float getBalance();
public abstract void setBalance(float bal);
public abstract String getName();
public abstract void setName(String n);
■
Container-managed relationship fields are likewise not declared as
instance variables. The class instead provides abstract get and set
methods for these fields, and the container provides the implementation for
these methods.
Table Mapping for CMP 2.0 is accomplished using the vendor-specific ejb-
borland.xml deployment descriptor. The descriptor is a companion to the ejb-
jar.xml descriptor described in the EJB 2.0 specification. Borland uses the
XML tag <cmp2-info> as an enclosure for table mapping data as needed. Then
you use the <table-properties> and its associated <column-properties> elements
to specify particular information about the entity bean's implementation. Use
Chapter 32, “ejb-borland.xml” for syntax of the XML grammar.
Optimistic Concurrency Behavior
The container uses optimistic or pessimistic concurrency to control the
behavior of multiple transactions accessing the same data. BES has four
optimistic concurrency behaviors which are specified as Table Properties.
These behaviors are:










