Chapter 9 Working with Object-Oriented Models


Class checks

The following OOM model checks are made on classes:

Check Description and Correction
Class name and code uniqueness Class names and codes must be unique in the namespace (model or package).

Manual correction: Modify the duplicate name/code

Automatic correction: Appends a number to the duplicate name/code
Empty classifier Attributes and operations are missing for this classifier.

Manual correction: Add attributes or operations to the classifier

Automatic correction: None
Persistent class without persistent attributes All attributes of a persistent class cannot be non-persistent.

Manual correction: Define at least one attribute as persistent

Automatic correction: None
Association class with identifier(s) An associated class should not have identifiers.

Manual correction: Remove the identifier

Automatic correction: None
Classifier visibility A private or protected classifier should be inner to another classifier.

Manual correction: Change classifier visibility to public or package

Automatic correction: Changes the visibility to public or package
Class constructor return type A constructor cannot have a return type.

Manual correction: Remove current return type of the constructor

Automatic correction: Removes current return type of the constructor
Class constructor modifiers A constructor cannot be static, abstract, or final.

Manual correction: Remove the static, abstract, or final property of the constructor

Automatic correction: Removes the static, abstract or final property of the constructor
Operation implementation When there is a realization between a class and an interface, you must implement the operations of the interface within the class. To do so, click the Operations tab in the class property sheet and select the To be Implemented button at the bottom of the tab to implement the missing operations.

Manual correction: Implement the operations of the interface within the class

Automatic correction: None
Role name assignment A navigable role will be migrated as an attribute into a class. The code of the association is used if the role has no name.

Manual correction: Assign a role name for the association role

Automatic correction: None
Role name uniqueness The name of the role is used by another role or by another attribute.

Manual correction: Change the name of the duplicate role

Automatic correction: None
JavaBean without a BeanInfo Bean implementors that provide explicit information about their beans must provide a BeanInfo class.

Manual correction: Create a BeanInfo class

Automatic correction: None
BeanInfo without a JavaBean class A BeanInfo class must depend on a JavaBean class.

Manual correction: Create a JavaBean class and recreate its BeanInfo, or delete the BeanInfo

Automatic correction: None
Emuneration type parent A enum may not have children.

Manual correction: Remove links to child classes.

Automatic correction: None
Bean class definition The Bean class must be defined as public. It must define a public constructor that takes no arguments and cannot define the finalize() method. It must be abstract for CMP Entity Beans but cannot be abstract or final for BMP Entity, Session and Message-driven Beans.

Manual correction: Change the class visibility to public, define a public constructor with no arguments, do not define the finalize() method

Automatic correction: Changes the class visibility to public, defines a public constructor with no arguments and removes the finalize() method. Corrects to set final = false, and set abstract = false
Bean class Business methods implementation For each method defined in the component interface(s), there must be a matching method in the Bean class that has the same name, number, return type and types of arguments.

Manual correction: Add a method with the same name, number, return type and types of arguments in the Bean class

Automatic correction: Adds a method with the appropriate values in the Bean class
Bean class Home interface methods implementation For each create<METHOD> method of the bean Home Interface(s), there must be a matching ejbCreate<METHOD> method in the Bean class with the same method arguments. For each home method of the Home Interface(s), there must be a matching ebjHome<METHOD> method in the Bean class with the same number and types of arguments, and the same return type.

The following check applies to Entity Beans only.

For each ejbCreate<METHOD> method of the Bean class, there must be a matching ejbPostCreate<METHOD> method in the Bean class with the same number and types of arguments.

Manual correction: Add a method with the same name and types of arguments in the Bean class

Automatic correction: Adds a method with the appropriate values in the Bean class

The following check applies to BMP Entity Beans only.

For each find<METHOD> finder method defined in the bean Home Interface(s), there must be a corresponding ejbFind<METHOD> method with the same number, return type, and types of arguments.

Manual correction: Add a method with the same number, return type and types of arguments in the bean Home Interface(s)

Automatic correction: Adds a method with the appropriate values in the bean Home Interface(s)
Bean class ejbCreate methods ejbCreate<METHOD> methods must be defined as public, and cannot be final nor static.

The following check applies to Entity Beans only.

The return type of an ejbCreate() method must be the primary key type.

Manual correction: Select the primary key in the Return type list of the Operation property sheet

Automatic correction: Selects the primary key as return type

The following check applies to Session Beans and Message Driven Beans.

The return type of an ejbCreate() method must be void.

Manual correction: Select void in the Return type list of the Operation property sheet

Automatic correction: Changes the return type to void

The following check applies to Message Driven Beans only.

The Bean class must define an ejbCreate() method that takes no arguments.

Manual correction: Add a method with no argument in the Bean class

Automatic correction: Adds a method with no argument in the Bean class
Bean class ejbPostCreate methods The following check applies to Entity Beans only.

ejbPostCreate<METHOD> methods must be defined as public, and cannot be final nor static. Their return type must be void.

Manual correction: Change the method visibility to public, deselect the final and static check boxes and select void in the Return type list of the Operation property sheet

Automatic correction: Changes the method visibility to public, changes the final and static check boxes and changes the return type to void
Bean class ejbFind methods BMP Entity Bean specific.

ejbFind<METHOD> methods must be defined as public and cannot be final nor static. Their return type must be the entity bean primary key type or a collection of primary keys.

Manual correction: Change the method visibility to public and deselect the static check box

Automatic correction: Changes the method visibility to public and deselects the static and final check boxes. Forces the return type of ejbFind<METHOD> to the primary key type
Bean class ejbHome methods ejbHome<METHOD> methods must be defined as public and cannot be static.

Manual correction: Change the method visibility to public and deselect the static check box

Automatic correction: Changes the method visibility to public and deselects the static check box
Bean class ejbSelect methods The following check applies to CMP Entity Beans only.

EjbSelect <METHOD> methods must be defined as public and abstract. Their throws clause must include the javax.ejb.FinderException.

Manual correction: Change the method visibility to public, select the abstract check box, and include the javax.ejb.FinderException

Automatic correction: Changes the method visibility to public, selects the abstract check box, and includes the javax.ejb.FinderException
Primary key class definition The following check applies to Entity Beans only.

The primary key class must be declared as public and must define a public constructor that takes no arguments.

Manual correction: Change the method visibility to public and add a default constructor in the primary key class

Automatic correction: Changes the method visibility to public and adds a default constructor in the primary key class
Primary key class attributes All primary key class attributes must be declared as public. In addition, each primary key class attribute must have a corresponding cmp-field in the Bean class.

Manual correction: Change the visibility to public, and create a cmp-field in the Bean class that has the same name and the same data type as the attribute of the primary key class

Automatic correction: Changes the visibility to public and creates a cmp-field in the Bean class that has the same name and the same data type as the attribute of the primary key class
Primary key class existence If the bean class has more than one primary key attribute then a primary key class must exist. If there is only one primary key attribute, it cannot have a standard data type, but must have an object data type (ex: java.lang.Long).

Manual correction: If there are many primary key attributes, create a primary key class. If there is only one primary key attribute, select an object/classifier data type

Automatic correction: Creates a primary key class, or selects the appropriate object/classifier data type
Class mapping not defined The class must be mapped to tables or views in the data source.

Manual correction: Define the mapping from the Mapping tab of the class property sheet. (Class Sources tab), or remove the data source

Automatic correction: Removes the data source from the Mapping For list in the class Mapping tab

For more information about O/R mapping, see the "Object to relational mapping" section in chapter "Using Mappings" in the General Features Guide
Attribute mapping not defined The attribute must be mapped to columns in the data source.

Manual correction: Define the mapping from the Mapping tab of the Class property sheet. (Attributes Mapping tab), or remove the data source

Automatic correction: Removes the data source from the Mapping For list in the class Mapping tab

For more information about O/R mapping, see the "Object to relational mapping" section in chapter "Using Mappings" in the General Features Guide
Incomplete bound classifier A classifier that is of type "Bound" must be bound to a generic classifier.

Manual correction: Specify a generic classifier in the field to the right of the type list on the General tab of the bound classifier's property sheet. You can also connect it to the generic classifier by way of a dependency with stereotype <<bind>>.

Automatic correction: None
Invalid generation mode If a class has its persistence mode set to Migrate Columns, it must have a persistent parent or child to which to migrate the columns

Manual correction: Link the class to a persistent parent or child, or change its persistence mode on the Detail tab of its property sheet.

Automatic correction: None

 


Copyright (C) 2007. Sybase Inc. All rights reserved.