Understanding EJB Code Generation

The code generation mechanism is only described for Entity beans CMP in this section since the code generated is handled and stored in the Container. With Entity beans BMP, session beans and message-driven beans, the code generated is highly dependent on the bean developer's input, it would thus not be possible to introduce each possible configuration here.

The process of code generation is explained below in order for you to understand the mechanism:

The generation of EJB class and interface into code is performed like if they were Java classes, except that they are dependent on an EJB and thus contain more information to be processed during generation.

The code generation process performs the following tasks:


  1. It creates the following inheritance links:


    • The local home interface inherits javax.ejb.EJBLocalHome

    • The local interface inherits javax.ejb.EJBLocalObject

    • The remote home interface inherits javax.ejb.EJBHome

    • The remote interface inherits javax.ejb.EJBObject

    Here is an example from the Preview page of the remote interface:



  2. It creates the following realization links:


    • The Primary key class implements java.io.Serializable

    • The Bean class implements javax.ejb.EntityBean

    Here is an example from the Preview page of the Bean class:



  3. It transforms attributes flagged as persistent into getter and setter methods (cmp-fields and cmr-fields are generated as getters and setters).

    cmp-fields are attributes flagged as Persistent in the property sheet. cmr-fields are attributes that are migrated from associations.

    Here is an example from the Preview page of the Bean class:




Created October 7, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com