There will be a problem, because framework will try to commit Detail record without any value for foreign key. There will be no value for foreign key, because Master record is still not committed and sequence number is not assigned for Master record primary key. When user will try to close transaction by committing new records from Master and Detail, integrity constraint violation error will be thrown by database:
From my practice, its quite common problem and many developers are facing this. However, there is one feature in Oracle ADF, that helps to solve described problem. You just need to open Entity Association wizard for those Entities involved into Master-Detail relationship:
And basically to select one checkbox in Behavior group, this checkbox is Composition Association. By selecting this option, you will force framework to use so called strong association between two Entities. With strong association, framework automatically will ensure correct foreign key value propagation for Detail record:
And there is no additional changes, Create functionality now will work for both - Master and Detail in the same transaction. Just make sure you didn't forgot to set DBSequence type for Primary Keys in your Entities. Both new records, Master and Detail, now can be commited together:
It works, but its important to know - when you are using Composite Association, you can't use Detail Entity without Master Entity in the same page. You can try to put Detail (in my case Departments Entity) into separate page and to invoke any CRUD operation, you will get Invalid Owner Exception:
More about this case you can read from Steve Muench blog - Why Do I Get the InvalidOwnerException?.
You can download and run my sample application - CreateMasterDetail.zip, developed with JDeveloper 11g for this post.
Spanish Summary:
El desarrollo de pantallas master-detail son comunes y sencillas de realizar usando ADF. Sin embargo, si se pretende grabar simultaneamente ambos registros, saldrá un error debido a que requerirá grabar primer la información que esta en cabecerá y luego la información que se encuentra en el detalle. Para evitar la salida de un error indecifrable, Andrejus nos muestra un tip muy útil en este post.