<<Entity>> classes

The UML to EJB transformation transforms a class that is marked with the <<Entity>> stereotype into a CMP 2.x, CMP 1.1, or BMP entity bean with a bean name that is equal to the name of the source UML class. The type of generated entity bean corresponds to the option that you select in the EJB transformation configuration window, on the Entity tab.

The transformation always generates the following Java classes for entity beans:

 

The transformation generates the following Java classes when, on the Entity tab, you click Remote Interfaces Only:

 

The transformation generates the following Java classes when, on the Entity tab, you click Local Interfaces Only:

 

The transformation generates the following Java classes when, on the Entity tab, you click Local and Remote Interfaces:

 

The transformation generates all classes in the package folder that is generated for the parent package of the source UML class. If you create a UML model without packages, the transformation generates a default package named ejbs.

The transformation generates the bean class and key class files in the source tree of the target EJB project.

The transformation generates the four interface files in the source tree of the client project of the target EJB project. If no client project exists, the transformation generates the interface files in the target EJB project.

The transformation adds data that defines the entity bean to the deployment descriptor (ejb-jar.xml).

Generalization relationships

If the source UML class for the entity bean has a generalization relationship (such as an extends relationship) with another UML class with the <<Entity>> stereotype, the entity bean that the class represents becomes the EJB superclass for the entity bean to be generated.

Both entity beans must be of the same type. Therefore, both entity beans must be CMP 2.x, CMP 1.1, or BMP. For example, if the super bean is a CMP 2.x entity bean, all child beans must be CMP 2.x entity beans. If the super bean is not the same type as the expected child bean, the transformation generates the child bean without a generalization relationship.

Realization relationships

If the source UML class for the entity bean has realization relationships (such as  implements relationships) with interface elements, the interfaces that the source interfaces represent are implemented by the four interfaces (remote, home, local, local home).

Unmarked attributes – CMP 2.x

The transformation transforms attributes on the source UML class into CMP fields on the entity bean with the properties listed in the following table:

CMP 2.x field property

CMP field value

Name

UML attribute name

Type

Type determined from the attribute type (See the “Type map” table.)

Key field

False

Generate field in bean implementation class

False

Generate getter and setter

True

Promote getter and setter to local interfaces

True (if local interfaces exist)

Promote getter and setter to remote interfaces

True (if remote interfaces exist)

IsArray

True if the UML attribute has a finite upper value

If the attribute type is that of another CMP 2.x entity bean, the transformation does not transform the attribute into a CMP field, but assumes that the attribute is part of an association that should be transformed into an EJB relationship. However, if the attribute type is that of another enterprise bean that is not a CMP 2.x entity bean, the transformation does not transform the attribute into a CMP field or an association. Instead, the transformation writes a message to the log file that states that the source attribute will not be transformed.

Unmarked attributes – CMP 1.1

The transformation transforms attributes on the source UML class into CMP fields on the entity bean with the properties listed in the following table:

CMP 1.1 field property

CMP field value

Name

UML attribute name

Type

Type determined from the attribute type (See the “Type map” table.)

Key field

False

Generate field in bean implementation class

False

Generate getter and setter

True

Promote getter and setter to local interfaces

False

Promote getter and setter to remote interfaces

True (always)

IsArray

True if the UML attribute has a finite upper value

If the attribute type is that of another entity bean or enterprise bean, the transformation does not transform the attribute into a CMP field or an association. Instead, the transformation writes a message to the log file that states that the source attribute will not be transformed.

Unmarked attributes – BMP

The transformation transforms attributes on the source UML class into BMP fields on the entity bean with the properties listed in the following table:

BMP field property

BMP field value

Name

UML attribute name

Type

Type determined from the attribute type (See the “Type map” table.)

Key field

False

Generate field in bean implementation class

True

Generate getter and setter

True

Promote getter and setter to local interfaces

True (if local interfaces exist)

Promote getter and setter to remote interfaces

True (if remote interfaces exist)

IsArray

True if the UML attribute has a finite upper value

If the attribute type is that of another entity bean or EJB, the transformation does not transform the attribute into a BMP field or an association. Instead, the transformation writes a message to the log file that states that the source attribute will not be transformed.

<<Id>> attributes – CMP 2.x and CMP 1.1

The transformation also transforms attributes on the source UML class that are marked with the <<Id>> attribute into CMP fields, but with different property values, as listed in the following table. These CMP fields help form the primary key.

CMP 2.x and CMP 1.1 field property

CMP field value

Name

UML attribute name

Type

Type determined from the attribute type (See the “Type map” table.)

Key field

True

Generate field in bean implementation class

False

Generate getter and setter

True

Promote getter and setter to local interfaces

False

Promote getter and setter to remote interfaces

False

IsArray

True if the UML attribute has a finite upper value

If the attribute type is that of another entity bean or enterprise bean, the transformation does not transform the attribute into a CMP key field or an association. Instead, the transformation writes a message to the log file that states that the source attribute will not be transformed.

<<Id>> attributes – BMP

The transformation also transforms attributes on the source UML class that are marked with the <<Id>> into BMP fields, but with different property values, as listed in the following table. These BMP fields help form the primary key.

BMP field property

BMP field value

Name

UML attribute name

Type

Type determined from the attribute type (See the “Type map” table.)

Key field

True

Generate field in bean implementation class

True

Generate getter and setter

True

Promote getter and setter to local interfaces

False

Promote getter and setter to remote interfaces

False

IsArray

True if the UML attribute has a finite upper value

If the attribute type is that of another entity bean or enterprise bean, the transformation does not transform the attribute into a BMP key field or an association. Instead, the transformation writes a message to the log file that states that the source attribute will not be transformed.

CMP and BMP field type map

As the following table illustrates, the transformation generates the CMP and BMP fields with types based on the source attribute type:

UML attribute type

CMP/BMP field type

boolean

boolean

byte

byte

char

char

float

float

int

int

long

long

short

short

Boolean

java.lang.Boolean

Byte

java.lang.Byte

Char

java.lang.Char

Float

java.lang.Float

Integer

java.lang.Integer

Long

java.lang.Long

Short

java.lang.Short

String

java.lang.String

other

Fully qualified name

 

Unmarked operations

The transformation transforms unmarked operations on the source UML class into business methods on the entity bean. Initially, the operation is transformed in the same manner as an operation on an unmarked UML class. The transformed operation is added to the classes listed in the following table, with some modifications.

Class

Method modifications

Bean class

No change

Local interface

Interface method

Remote interface

Interface method, throws java.rmi.RemoteException

 

<<Query>> operations – CMP 2.x

The transformation transforms <<Query>> operations on the source UML class into one of two types of query methods: finder methods and select methods. Select methods exist only in CMP 2.x entity beans.

The transformation generates finder methods in the classes listed in the following table, with some modifications:

Class

Method modifications

Local home interface

(if local interfaces exist)

  • Name of findXxx (See the “Finder name” table.)
  • Throws javax.ejb.FinderException
  • Return type (See the “Finder return type” table.)

Remote home interface

(if remote interfaces exist)

  • Name of findXxx (See the “Finder name” table.)
  • Throws javax.ejb.FinderException
  • Throws java.rmi.RemoteException
  • Return type (See the “Finder return type” table.)

 

Finder name

UML operation name

Finder method name

xxx

findXxx

findXxx

findXxx

FindXxx

findXxx

 

Home interface finder return type

Java transform parsed return type

Finder method return type

Collection

java.util.Collection

Set

java.util.Set

List

java.util.Collection

SortedList

java.util.Set

<source class name>[]

java.util.Collection

<source class name> OR “void”

  • Local interface name
  • Remote interface name

<user defined type name>[]

java.util.Collection

<non source class name (for example, String, Integer, and so on)>[]

java.util.Collection

<user-defined type name>

Generate a select method instead of a finder method

<non-source class name (for example, String, Integer, and so on)>

Generate a select method instead of a finder method

 

The EJB transformation creates a task that indicates that you need to manually add a query to the deployment descriptor for each generated finder method.

The transformation transforms a query operation into a select method if the visibility on the operation is private, or if the return type is different from the name of the source UML class and the entity bean type is CMP 2.x.

Operation visibility

Return type

Method type

Private

Equal to the source class name

Select method

Not private

Equal to the source class name

Finder method

Private

Not the source class name

Select method

Not private

Not the source class name

Select method

 

The transformation generates select methods in the bean class, with the following modifications:

 

Select name

UML operation name

Select  method name

xxx

ejbSelectXxx

selectXxx

ejbSelectXxx

SelectXxx

ejbSelectXxx

ejbSelectXxx

ejbSelectXxx

 

Select return type

Java transform parsed return type

Select method return type

Collection

java.util.Collection

Set

java.util.Set

List

java.util.Collection

SortedList

java.util.Set

<source class name>[]

java.util.Collection

<source class name> OR “void”

Local Interface name

<user defined type name>[]

java.util.Collection

<non source class name (for example, String, Integer, and so on)>[]

java.util.Collection

<user-defined type name>

User-defined type name

<non-source class name (for example, String, Integer, and so on)>

Non-source class name

The EJB transformation creates a task that indicates that you need to manually add a query to the deployment descriptor for each generated select method.

<<Query>> operations – CMP 1.1

The transformation transforms <<Query>> operations on the source UML class into one type of query method: finder methods. CMP 1.1 entity beans do not support select methods, as they are only available for CMP 2.x entity beans. Therefore, regardless of the return type and visibility of the <<Query>> operation, the transformation always generates a finder method in the remote home interface of the entity bean.

As the following table illustrates, the transformation always generates finder methods in the remote home interface, with some modifications:

Class

Method modifications

Remote home interface

  • Name of findXxx (See the “Remote home interface finder name” table.)
  • Throws javax.ejb.FinderException
  • Throws java.rmi.RemoteException
  • Return type (See the “Remote home interface finder return type” table.)

 

Remote home interface finder name

UML operation name

Finder method name

xxx

findXxx

findXxx

findXxx

FindXxx

findXxx

 

Remote home interface finder return type

Java transform parsed return type

Finder method return type

Collection

java.util.Collection

Set

java.util.Set

List

java.util.Collection

SortedList

java.util.Set

<source class name>[]

java.util.Collection

<source class name> OR “void”

Remote interface name

<user defined type name>[]

java.util.Collection

<non source class name (for example String, Integer, and so on)>[]

java.util.Collection

<user-defined type name>

Remote interface name

<non-source class name (for example, String, Integer, and so on)>

Remote interface name

The EJB transformation creates a task that indicates that you need to manually add a query to the deployment descriptor for each generated finder method.

<<Query>> operations – BMP

The transformation transforms <<Query>> operations on the source UML class into one type of query method: finder methods. BMP entity beans of any version do not support select methods, as they are only available for CMP 2.x entity beans. Therefore, regardless of the return type and visibility of the <<Query>> operation, the transformation always generates a finder method in the bean implementation class. The transformation then generates finder methods in the existing interfaces of the entity bean.

As the following table illustrates, the transformation generates finder methods in the following classes, with some modifications:

Class

Method modifications

Local home interface
(if local interfaces exist)

  • Name of findXxx (See the “(Local) Remote home finder name” table.)
  • Throws javax.ejb.FinderException
  • Return type (See the “(Local) remote interface finder return type” table.)

Remote home interface

(if remote interfaces exist)

  • Name of findXxx (See the “(Local) Remote home finder name” table.)
  • Throws javax.ejb.FinderException
  • Throws java.rmi.RemoteException
  • Return type (See the “(Local) Remote interface finder return type” table.)

Bean implementation class

  • Name of ejbFindXxx (See the Bean class finder name table.)
  • Throws javax.ejb.FinderException
  • Return type (See the “Bean class finder return type” table.)

 

(Local) Remote home finder name

UML Operation name

Finder method name

xxx

findXxx

findXxx

findXxx

FindXxx

findXxx

ejbFindXxx

findEjbFindXxx

EjbFindXxx

findEjbFindXxx

 

Bean class finder name

UML Operation name

Finder method name

xxx

ejbFindXxx

findXxx

ejbFindXxx

FindXxx

ejbFindXxx

ejbFindXxx

ejbFindEjbFindXxx

EjbFindXxx

ejbFindEjbFindXxx

 

Home interface finder return type

Java transform parsed return type

Finder method return type

Collection

java.util.Collection

Set

java.util.Set

List

java.util.Collection

SortedList

java.util.Set

<source class name>[]

java.util.Collection

<source class name> OR “void”

  • Local interface name
  • Remote interface name

<user defined type name>[]

java.util.Collection

<non source class name (for example, String, Integer, and so on)>[]

java.util.Collection

<user-defined type name>

  • Local interface name
  • Remote interface name

<non-source class name (for example, String, Integer, and so on)>

  • Local interface name
  • Remote interface name

 

Bean class finder return type

Java transform parsed return type

Finder method return type

Collection

java.util.Collection

Set

java.util.Set

List

java.util.Collection

SortedList

java.util.Set

<class name>[]

java.util.Collection

<class name> OR “void”

Key class name

 

Inner classes

Ignored.

Inner interfaces

Ignored.

Terms of use | Feedback
(C) Copyright IBM Corporation 2004.
All Rights Reserved.