Features of WebLogic’s CMP
This section examines a number of WebLogic features that distinguish WebLogic’s CMP implementation. These include convenience features such as automatic generation of primary keys for new EJB instances, automatic creation of DBMS tables that map to the abstract persistent model, and more performance-oriented features such as statement batching, optimistic concurrency, and fetching preconfigured groups of fields. Later in this chapter, we look at two optimizations for container-managed EJB relationships: enabling the DBMS to take charge of cascading an EJB remove to related EJB instances and relationship caching.
Automatic Primary Key Generation
WebLogic can generate primary key
values automatically for noncompound primary key fields. To support
this, the primary key class element in the
ejb-jar.xml file must be either
java.lang.Integer
or
java.lang.Long
. The keys can be generated in two
ways: WebLogic can either delegate the primary key generation to the
DBMS, or it can use a named sequence table.
DBMS-generated primary keys
If you are using either Oracle or Microsoft’s SQL Server, WebLogic can use the underlying DBMS to generate primary keys. In Oracle, the EJB container accomplishes this using Oracle’s sequences. When a new primary key is needed, it calls on the sequence (or increments a cached sequence number). For SQL Server, it uses identity columns, which means that the primary key value is supplied automatically by the DBMS when the row is inserted. ...
Get WebLogic: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.