Part 6: Adding a Container-managed Relationship

Previous topic
Previous
Next topic
Next

Information to be included in a future release.

 

Drag the Employees table and drop it onto the UML model.

Double-click the relationship to show off the EJB Module Editor's version.

Rename Employees to Emp.

Create a new method in the UML model,

listEmployees (hr.DeptPK pk) : java.util.Collection

listEmployees (hr.Dept pk) : EmpLocal

Edit code for listEmployees(), copy and paste code in (make sure it points to the classpath of the EJB project).

  public EmpLocal listEmployees(DeptPK pk)
  {
   try {
        return this.getDeptLocalHome().findByPrimaryKey(pk).getEmployees();
       }
       catch(NamingException ne)
        {
        	System.out.println(ne.toString());
          throw new javax.ejb.EJBException(ne);
         }
       catch(FinderException fe)
          {
           System.out.println(fe.toString());
            throw new javax.ejb.EJBException(fe);
          }
  }

Add the following to the imort block:

import hr.EmpLocal;

Run.

Create sample Java client.

Run supplied JSP client.