Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (

Part Number E13981-01
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

Configuring a Container-Managed Persistent Field for an EJB 2.1 Entity Bean With Container-Managed Persistence

You do not define container-managed persistent fields in the entity bean class: container-managed persistent fields are virtual only. OC4J supplies the implementation of the container-managed persistent fields.

You must define public, abstract getter and setter methods for the container-managed persistent fields, using the EJB conventions (see "Using Java"). OC4J supplies the implementation of these methods. You must not expose these getter and setter methods in the remote interface of the entity bean.

You may assign only the following Java types to container-managed persistent fields: Java primitive types and Java serializable types. You may not assign an entity bean local interface type (or a collection of such) to a container-managed persistent field.

The container-managed persistent fields must be specified in the ejb-jar.xml deployment descriptor using the cmp-field element (see "Using Deployment XML"). The names of these fields must be valid Java identifiers and must begin with a lowercase letter, as determined by java.lang.Character.isLowerCase.


In this release, orion-ejb-jar.xml file <entity-deployment> subelement <cmp-field-mapping> is not used. For more information, see "<entity-deployment>".

The accessor methods must bear the name of the cmp-field that is specified in the deployment descriptor, and in which the first letter of the name of the cmp-field has been upper cased and prefixed by get or set.

For more information, see "What are Container-Managed Persistent Fields?".

Using Java

Example 14-4 shows the abstract getter and setter methods for the container-managed persistent fields specified in the ejb-jar.xml file (see "Using Deployment XML").

Example 14-4 EJB 2.1 Container-Managed Persistent Fields

package cmpapp;

import javax.ejb.*;
import java.rmi.*;

public abstract class EmployeeBean implements EntityBean {

    private EntityContext ctx;

    // container-managed persistent fields accessors
    public abstract Integer getEmpNo();
    public abstract void setEmpNo(Integer empNo);
    public abstract String getEmpName();
    public abstract void setEmpName(String empName);
    public abstract Float getSalary();
    public abstract void setSalary(Float salary);

Using Deployment XML

Example 14-5 shows the cmp-field elements for the getter and setter methods specified in the bean class (see "Using Java").

Example 14-5 ejb-jar.xml for an EJB 2.1 Container-Managed Persistent Field