Monday, January 10, 2011

How to prevent delete on master if child record exists in Oracle ADF


In this post we will see how to stop deletion of Master record if child record exists in the database without writing much code.

In this example we have only Departments entity and Employee view object i created a ViewLink between DepartmentsView and EmployeesView and accessing the ViewAccessor in Departments entity.

Later i override the remove() method as follows

  public void remove() {
    RowIterator ri = getEmployeesView();
    int count = ri.getRowCount();
    if (count > 0) {
      throw new JboException("You cannot delete this record, Child record exists!!!");
    } else {


Download the sample code.

feel free to add more suggestions.

Have a nice day,
Zeeshan Baig


  1. You the man! This helped out a lot. The only difference in my code is I didnt have a view link setup, i just had an accessor provided from the assocation.

    Is there a way to do this in Groovy? Like in Entity Object business rules?

  2. I don't see where you do it declaratively. I've looked at the sample code. Please point it out.

    1. Hi,

      Looks like the word "declarative" is a typing mistake here. I have removed it :)


    2. Thanks for pointing out though.