uCosminexus Application Server, EJB Container Functionality Guide

[Contents][Glossary][Index][Back][Next]

4.3.4 Precautions during the implementation of an Entity Bean (CMP)

This subsection describes the precautions to be taken when implementing an Entity Bean (CMP).

Organization of this subsection
(1) About accessing the resource manager with the setEntityContext method
(2) Precautions concerning the use of a user-defined type CMP field
(3) Precautions concerning transactions during the use of a CMR field
(4) Precautions concerning the usage of cascade-delete of CMR
(5) About specifying an interface in the primary key class
(6) Releasing the references with the remove method
(7) Notes on the finder or select methods of EJB QL

(1) About accessing the resource manager with the setEntityContext method

According to the EJB 1.1 specifications and EJB 2.0 specifications, accessing the resource manager with the setEntityContext method is not allowed.

(2) Precautions concerning the use of a user-defined type CMP field

In the cases other than when you use a compound primary key as the primary key, you cannot use a user-defined type CMP field.

(3) Precautions concerning transactions during the use of a CMR field

When using a Collection-type CMR field, or an Iterator of the Collection-type CMR field, you can access the CMR field and Iterator within the scope of the transaction when the CMR field is acquired. In the callTeam method of the following coding example, you must execute the getPlayers method that is the getter method of the CMR field, and all the operations using the succeeding Iterator in the same transaction (between [a] and [b]).

   public void callTeam() {
             ...
     //[a]
     Collection playersInTeam = team.getPlayers();
     Iterator i = playersInTeam.iterator();
     while (i.hasNext()) {
       LocalPlayer p = (LocalPlayer) i.next();
             ...
     }
     //[b]
   }

If you execute this coding example outside the transaction, the IllegalStateException exception will occur. To avoid this, specify the settings in CMT to execute within the transaction.

(4) Precautions concerning the usage of cascade-delete of CMR

The following limitations are applicable for using the cascade-delete of CMR:

(5) About specifying an interface in the primary key class

When an interface and the abstract class are specified in the <prim-key-class> tag of the DD of a CMP Entity Bean, the error message KDJE42039-E is output during the deployment, and the deployment processing terminates with an error.

(6) Releasing the references with the remove method

When you invoke an Entity Bean by using the home interface, you obtain the references by invoking the create method of the home interface; however, after completing the invocation of the Entity Bean, make sure that you release the references by invoking the remove method.

If you do not release the references, the memory on the J2EE server will be consumed.

(7) Notes on the finder or select methods of EJB QL

You cannot specify an array as the argument type of the finder or select methods of EJB QL.