Relationships for CMP 1.x are not standard to the EJB 1.x specification. WebSphere® Application Server extensions were created to handle 1.x relationships.
Use the EJB deployment descriptor editor to specify the relationship between two enterprise beans in your EJB project or module. The EJB deployment descriptor editor generates the appropriate finder methods to support any relationships that you create.
When you define a relationship from one CMP to another, extra CMP fields based on the key fields from the referencing CMP bean are added to the owning CMP bean of the forward referencing role (Foreign Key check box is selected on the owning CMP bean).
For example, Company has a 1..N relationship to Employee with roles company and employees respectively. The company role is forward and the Company CMP bean has key fields named "companyID" and "companyName." The CMP fields that are automatically added to the Employee bean are "company_companyID" and "company_companyName." These fields are hidden in the EJB editor because they are fields that were added to support the "employee" relationship role. Problems would arise if these CMP fields were removed from the ejb-jar.xml file while the relationship still existed.
More examples of relationships can be seen in the AutoWorld example project that is shipped with Rational® Application Developer. The picture below shows how the Garage-Vehicle relationship appears on the Relationships page of the EJB deployment descriptor editor. Multiple Vehicles can be housed in a single Garage, so the multiplicity indicates a Many (0..*) to 1 (0..1) relationship.
The creation wizard displays the UML view of the relationship and the fields are modified based on the UML model. When a relationship is created, additional classes are created to support the runtime in maintaining the links between these two beans. Also, additional methods will be generated into the Home, Remote, and Bean classes of both enterprise beans. You will see compile errors in the EJB deployment descriptor editor when a relationship is first created because the generated Link classes need to be compiled. You will see the actual code in these files but the changes in the Homes, Remotes, and Bean classes have not yet been compiled. This will not take place until the project is built; this usually happens automatically when the EJB deployment descriptor editor is saved. Therefore, you will not see compile errors until the editor is saved.
To create a relationship between two enterprise beans (CMP 1.x ):