Forum Stats

  • 3,815,687 Users
  • 2,259,067 Discussions
  • 7,893,207 Comments

Discussions

How to handle DB exceptions in a master-detail association (NOT COMPOSITE)

Robert Šajina
Robert Šajina Member Posts: 94
edited Jan 30, 2018 3:53AM in JDeveloper and ADF

Hi all,

we have a use case with master detail association between entities. We didn't set the association as composite, because of validation reasons.

We have copied the code for master detail posting which is suggested in 12.2.1.2.0.  (Chapter:  4.14.7 How to Control Entity Posting Order to Prevent Constraint Violations)
This all works as it should, but the problem occurs if we get an error from the database trigger when posting the data.

In the documentation, there is no sample or code suggested for handling DB application errors.

When the error occurs master losses its children, but after executing query on master iterator the row appears again, but with some mixed values.

This problem only occurs after the master entity is new, after first commit attempt the master entity is somehow not new any more.

Also there is no problem with commited entities (retrieved from DB).

We tried to solve this problem by overriding the handlePostChangesError() on MasterEntityImpl and calling handlePostChangesError  on

super and all children, but with no success.

Is there a way to solve this issue? Is there any example on how to handle this kind of errors?

With composite association, on this master-detail association everything works fine.

When posting the records adf creates new records and new RowIterators for children. Does calling hanldePostChangesError even matter?

Thank you,

JDev 12.2.1.2.0.

Robert

Tagged:

Answers

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Jan 29, 2018 10:19AM

    Hello,

    For handling errors from DB i recommend this sample:Oracle ADF

    It help me very much (it also handles view controller errors, but you use it for what is your requirement).

    Regards,

    Carlos

  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Jan 30, 2018 3:31AM

    Hi Carlos,

    thank you for your response,

    i have already went through the documentation and samples before, and that doesn't solve my problems.

    In my case i need somehow revert the changes on detail rows when the db error occurs on postChanges() method.

    I only have a problem when the master record is new. When posting the data if error occurs from db, detail rows are lost.

    I understand that ADF creates new rows after calling postChanges(), so that might be a problem?

    ***Moderator action (Timo): removed callout to members who have not participated in this thread already.***

    what do you think about this?

    Regards,

    Robert

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Jan 30, 2018 3:53AM

    Hello,

    I must say i never worked with master detail tables, so i do not know what you are facing exactly.

    The issues from DB(not only) i faced were solved with that tutorial from @Frank Nimphius-Oracle.

    Sorry not being more helpful, unless you provide a test case ( ) with HR Schema.

    Do not forget to provide any script to run in DB too.

    Regards,

    Carlos

This discussion has been closed.