Developing enterprise beans

Before you begin

Design a J2EE application and the enterprise beans that it needs.

Why and when to perform this task

There are two basic approaches to selecting tools for developing enterprise beans:

The following steps primarily support the second approach, development without an IDE.

Steps for this task

  1. If necessary, migrate any pre-existing code to the required version of the Enterprise JavaBeans (EJB) specification.
  2. Write and compile the components of the enterprise bean.
    • At a minimum, an EJB 1.1 session bean requires a bean class, a home interface, and a remote interface. An EJB 1.1 entity bean requires a bean class, a primary-key class, a home interface, and a remote interface.
    • At a minimum, an EJB 2.0 session bean requires a bean class, a home or local home interface, and a remote or local interface. An EJB 2.0 entity bean requires a bean class, a primary-key class, a remote home or local home interface, and a remote or local interface. The types of interfaces go together: If you implement a local interface, you must define a local home interface as well.

      Note: Optionally, the primary-key class can be unknown. See unknown primary-key class for more information.

    • Available only through EJB 2.0, a message-driven bean requires only a bean class.
  3. For each entity bean, complete work to handle persistence operations.
    • Create a database schema for the entity bean's persistent data.
      • For entity beans with container-managed persistence (CMP), you must store the bean's persistent data in one of the supported databases. WebSphere Application Server application assembly tools automatically generate SQL code for creating database tables for CMP entity beans. If your CMP beans require complex database mappings, it is recommended that you use the IBM WebSphere Studio Application Developer product to generate code for the database tables.
      • For entity beans with bean-managed persistence (BMP), you can create the database and database table by using the database tools or use an existing database and database table.

      For more information on creating databases and database tables, consult your database documentation.

    • (CMP entity beans for EJB 2.0 only) Define finder queries with EJB Query Language (EJB QL).

      With EJB QL, you define finders in terms of CMP fields and container-managed relationships, as follows:

      • Public finders are visible in the bean's home interface. Implemented in the bean class, they return only remote interfaces and collection types.
      • Private finders, expressed as SELECT statements, are used only within the bean class. They can return both local and remote interfaces, dependent values, other CMP field types, and collection types.

    • (CMP entity beans for EJB 1.1 only: an IBM extension) Create a finder helper interface for each CMP entity bean that contains specialized finder methods (other than the findByPrimaryKey method).

      The following logic is required for each finder method (other than the findByPrimaryKey method) contained in the home interface of an entity bean with CMP:

      • The logic must be defined in a public interface named NameBeanFinderHelper, where Name is the name of the enterprise bean (for example, AccountBeanFinderHelper).
      • The logic must be contained in a String constant named findMethodName WhereClause, where findMethodName is the name of the finder method. The String constant can contain zero or more question marks (?) that are replaced from left to right with the value of the finder method's arguments when that method is called.

What to do next

[5.0 only][Version 5.0.1][Version 5.0.2]Assemble the beans in one or more EJB modules.


Related concepts
Enterprise beans
Concurrency control
Related tasks
Developing applications that use JNDI
Related reference
WebSphere extensions to the Enterprise JavaBeans specification
Best practices for developing enterprise beans
Enterprise beans: Resources for learning
Unknown primary-key class



Searchable topic ID:   tejbdvdp
Last updated: Jun 21, 2007 9:56:50 PM CDT    WebSphere Application Server for z/OS, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.zseries.doc/info/zseries/ae/tejb_dvdp.html

Library | Support | Terms of Use | Feedback