Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Entity Bean Configuration and Deployment

As you saw in a the third article in this series, the root <ejb-jar> element contained an <enterprise-beans> element, which contained a collection of <session> elements. Instead of containing just <session> elements, the <enterprise-beans> element can also contain a collection of <entity> elements. Each <entity> element is used to describe the configuration and deployment of an individual entity bean.

The <entity> bean element, shown in Listing 1, defines entity bean metadata; a unique name in the EJB JAR file; the bean's class, interface, and primary key names; the type of entity bean; configuration parameters; references to other EJBs and database connections; security semantics; and elements to assist in the object-relational mapping for CMP entity beans. As an example, the entity-related elements of a CMP entity TShirt bean's ejb-jar.xml file are shown in Listing 1. You'll note that for the TShirt EJB, its <persistence-type> is marked as Container and a set of <cmp-field> elements defines the container-managed fields of this EJB. The primary key class field is indicated in the <primkey-field> as the SHIRT_ID field, which is of type java.lang.Integer, as defined in the <prim-key-class> field.

Listing 1 Example of EJB Entity Bean Deployment Descriptor Information

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//
[ic:ccc]DTD Enterprise JavaBeans 1.1//EN'
[ic:ccc] 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

 <description>no description</description>






Vendor-specific deployment descriptor files to configure and deploy entity beans are also needed. Developers most often use GUI-based deployment tools provided by vendors to develop such files. What is perhaps most important about these vendor-specific XML files (aside from the JNDI-to-EJB name mappings for all EJBs) is the object-to-relational mappings that they contain for CMP entity EJBs.

  • + Share This
  • 🔖 Save To Your Account