When creating standard CMP entity beans, the standard ejb-jar.xml descriptor file is used to define the persistent fields for the CMP entity bean, its primary key class, and the nature of its relationships with other entity beans. The weblogic-ejb-jar.xml descriptor file hosts the WebLogic counterpart to this information. In addition, you need to create a weblogic-cmp-rdbms-jar.xml descriptor file that maps these “virtual fields” to actual table columns in the underlying database. The weblogic-cmp-rdbms-jar.xml file allows you to configure all aspects of WebLogic’s RDBMS-based persistence services for CMP entity beans. It lets you specify the database columns associated with the persistent fields, the primary key columns that identify the EJB instances, and the foreign key columns that implement the EJB relationships.
Due to the sheer number of descriptor files and source files that
need to be maintained, the easiest approach to developing entity
beans is to use
EJBGen, or IDEs such as WebLogic
Workshop. The following sections show a working example of this
approach, together with an outline of the descriptor files. If you
don’t want to use
you have to create, by hand, the same set of descriptor files
described in the following sections.
Example 11-1 shows the complete code for a simple CMP
entity bean. It uses WebLogic’s
GenericEntityBean class to simplify the
Example 11-1. The Department EJB abstract class