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).
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.
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).
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.
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.
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.
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.
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.
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 |
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 |
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) |
|
Remote home interface (if remote interfaces exist) |
|
UML operation name |
Finder method name |
xxx |
findXxx |
findXxx |
findXxx |
FindXxx |
findXxx |
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” |
|
<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:
UML operation name |
Select method name |
xxx |
ejbSelectXxx |
selectXxx |
ejbSelectXxx |
SelectXxx |
ejbSelectXxx |
ejbSelectXxx |
ejbSelectXxx |
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.
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 |
|
UML operation name |
Finder method name |
xxx |
findXxx |
findXxx |
findXxx |
FindXxx |
findXxx |
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.
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 |
|
Remote home interface (if remote interfaces exist) |
|
Bean implementation class |
|
UML Operation name |
Finder method name |
xxx |
findXxx |
findXxx |
findXxx |
FindXxx |
findXxx |
ejbFindXxx |
findEjbFindXxx |
EjbFindXxx |
findEjbFindXxx |
UML Operation name |
Finder method name |
xxx |
ejbFindXxx |
findXxx |
ejbFindXxx |
FindXxx |
ejbFindXxx |
ejbFindXxx |
ejbFindEjbFindXxx |
EjbFindXxx |
ejbFindEjbFindXxx |
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” |
|
<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> |
|
<non-source class name (for example, String, Integer, and so on)> |
|
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 |
Ignored.
Ignored.
Terms
of use | Feedback
(C) Copyright IBM Corporation 2004. All Rights Reserved.