Step 2: Adding an addDepartment() method to the Session Bean |
Previous |
Next |
Now that your Dept entity ejb has a new create method, you'll want to call that from the session bean facade.
To add the create() method to the session facade:
addDepartment(Long deptno, String dname, Long location) : voidimport javax.ejb.CreateException;
public void addDepartment(Long deptno, String dname, Long location)
{
try {
this.getDeptLocalHome().create(deptno,dname,location);
}
catch(NamingException ne)
{
System.out.println(ne.toString());
throw new javax.ejb.EJBException(ne);
}
catch(CreateException ce)
{
System.out.println(ce.toString());
throw new javax.ejb.EJBException(ce);
}
}