Monday, March 4, 2013

ADF: Traversing Associations

JDeveloper generates accessor methods for each association:
  1. a getter and a setter in the destination to retrieve the source
  2. a getter in the source to get the destination.
To delete all of the child entity rows in an entity association relation.

    public void remove() {
        // get the department employeess accessor
        RowIterator deptEmployees = getEmployeeEO();
        // iterate over all department employees
        while (deptEmployees.hasNext()) {
            // get the department employee
            EmployeeEOImpl deptEmployee = (EmployeeEOImpl);
            // remove employee

To delete a department when the last department employee is deleted.

    public void remove() {
        DepartmentEOImpl department = getDepartmentEO();
        int numberOfEmp = department.getEmployeeEO().getRowCount();
        // check whether last employee in the department
        if (numberOfEmp == 1) {
            // delete the last employee
            // delete the department as well
        } else {
            // just delete the employee

No comments:

Post a Comment