Detail entity with row key null cannot find or invalidate its owning entity.


  1. in the model project go to the association.
  2. double click on the association and expand the behavior node under relationship tab.
  3. make sure that the primary key column is set to DBsequance, if you have a sequence on the database or a function that generate the db sequence from a trigger

3- check on composition association and cascade update key attribute

4- When an entity row is created it's row status is STATUS_NEW . This means row is added in the transaction's list of changes to be validated or posted or committed. This is fine and expected in most of the cases. However, during complex business objects like master-detail there comes the situation where you may want to turn off these validations until both master and detail are available. For such situations to remove the row from transactions's list of changes ADF exposes an api setNewRowStatus(ROW.STATUS_INITIALIZED).

This is specifically helpful when master-detail association is a composite association and situation demands to create the detail rows before the master row. In that case without setting the row status to STATUS_INITIALIZED you will face:


JBO-25030: Detail entity with row key null cannot find or invalidate its owning entity.


There is no harm programatically changing the row status to STATUS_INITIALIZED or STATUS_NEW using the setNewRowStatus api as long as you understand its implications.

5- if all the above suggestions does not work , you have to try this solution
  Do The following:
  A- Double click on the detail view object and click on java tab    and check on "Generate view row class".

   



  B- in the application module impl class "ApplicationModuleImpl"    add this method:
    
     public void addDocTypeViewRow(){
        ViewObjectImpl details = this.getDocTypeView();  
        ViewObjectImpl master = this.getAllDocTypesView();
        Row masterRow =master.getCurrentRow();        
        NameValuePairs pairs = new NameValuePairs();
        System.out.println(masterRow.getAttribute("Id"));
        pairs.setAttribute("AdtId",         masterRow.getAttribute("Id"));
        DocDocTypeViewRowImpl row = (DocDocTypeViewRowImpl) details.createAndInitRow(pairs);
        details.insertRow(row);
        details.setCurrentRow(row);        
    }

Change "getDocTypeView" with the method name of the detail view object 
and change "getAllDocTypesView" with the method name of the master view object

to be notice , the view object method name is added to the application module impl class just when you add this view object in the data model


C- Expose the addDocTypeViewRow() method to client interface as shown:

D- Refresh the Data control to view the new method added to your data control
E-Drag and drop the method into your page as a button. This button is a replacement of the ordinary "CreateInsert" operation.  This button shall create a new record in the details view object.

another solution:

1
2
3
4
oracle.jbo.InvalidOwnerException: JBO-25030: Failed to find or invalidate
owning entity: detail entity Emp, row key oracle.jbo.Key[-5 ].
at oracle.jbo.server.EntityImpl.internalCreate(EntityImpl.java:1048)
at oracle.jbo.server.EntityImpl.create(EntityImpl.java:811)
if you the above exception whn u create master /detail table then do the following
  1. Cascade Update Key Attributes” in association should be checked
  2. In viewRowImpl add
1
2
3
4
5
6
@Override
public void setNewRowState(byte state) {
 if (state != Row.STATUS_INITIALIZED || getNewRowState() != Row.STATUS_NEW) {
 super.setNewRowState(state);
 }
}






Comments

Sergio SPAIN said…
Your blog save me in this ocasion and I put it on my Favourites because sure it will help me in other situations.

Thanks so much!!!
Tarek Fathy said…
Thank you Sergio SPAIN for you comment
Sameer said…
"make sure that the primary key column is set to DBsequance"

I am new to ADF so this might seem a bit silly. But when you say the above you mean to check in the EO and not the AO right?

Also, in EO where do we specify the DB sequence name?

Thanks,
Tarek Fathy said…
-Yes , check the EO " Entity object" not the AO.
-In EO you just click on attributes then double click on the primary key attribute, the in the "Type" property select DBSequance from the drop down list. Make sure that you have a database sequance on the database that generate a number for this attribute
Unknown said…
Thank You very much,your addDocTypeViewRow(){} part has resolved my issue, Thank You once again.
Unknown said…
Thanks. This Worked for me :)

Just one question, So in the future if I want the master-detail dependence i.e. the child table and parent table should both be populated in the same transaction, Do i need to uncheck the 'Cascade Updae Key Attribute' in Association?
Tarek Fathy said…
you need to check 'Cascade update key attribute' only in case the primary key attribute of the master is generated by a database trigger.in this case only you must check this option
Anonymous said…
Thanks this helped me

Regards

Popular posts from this blog

Another user has changed the row with primary key oracle.jbo.Key[12 ].

weblogic windows JPS-01050: Opening of wallet based credential store failed. Reason java.io.IOException: Failed to lock cwallet.sso.lck

Working With File Throgh WebUtill