Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ADF Parent-Child tables rules

LausMay 4 2015 — edited May 6 2015

Hi,

I use JDeveloper and ADF 12.1.3. Now I have a set of parent tables, and each of them have only one child table.

I have master-detail jsf page for every parent-child table. Inside of it, I can insert one row in parent table, and multiple rows in child table. Commit is done on singe commit button for booth tables. Link between master (parent table) and detail (child table) is done via assocciation and view link for UI.

Now here is the rule I need to apply: I can't commit newly created row to parent table without at least one new inserted row in child table.

Because I have multiple parent-child tables in this use case, I wanted to make override to EntityImpl class and add newly created class to each parent table, so I have bussines logic in one place for this tables.

Let's look and sample for one parent table (not overriden EntityImpl class):

Inside generated parent EO class

    @Override

    public void beforeCommit(TransactionEvent transactionEvent){      

        // TODO Implement this method

        if (!validateParentChildNumber()) {

            throw new JboException("Not allowed.");

        }

        super.beforeCommit(transactionEvent);

    }

    public boolean validateParentChildNumber() {

        if(getParentChild().getRowCount()>0)

        return true;

        else

        return false;

    }

This works ok. If I insert one row in parent table and one or more rows in child table the commit will pass. But if I get one row inside parent table and no rows in child tables I get Not allowed message in my browser.

So here is where problem lis. Once I get Now allowed message, no matter if I insert new chield row, I cant commit until I restar my app. Why? Because now I have constantly this message:

ORA-02291: integrity constraint (RE.FK_PAR_PAR_ID) violated - parent key not found

It's like I cant commit existing parent row that I inserted before missing child row. Why this happens? Should I override postChanges method and what to put in it?

Many thx

This post has been answered by Cvele_new_account on May 6 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2015
Added on May 4 2015
12 comments
1,143 views