Can you give us an example of inserting a new master and details with composition in play?
I frequently get asked about how to insert a new master row and new detail rows when the association between the master and detail have been marked as a composition. If you don't follow the tips that I highlight in this "Why does I get Invalid Owner Exception?" article, you might end up getting that error in your code.
Here's a working sample to download and study: InsertNewComposedMasterAndDetail.zip
The mini-manual to running the example is:
- Run the CreateEmpDeptTables.sql script (if you don't already have EMP and DEPT or want to reset the data to be as expected by the example).
- Run TestClient.java
The result is that:
- A new department 99 should be created with four new employees
- Existing department 10 should have two new employees
- An error about non-existent department 88 will be printed.
2:49:33 PM
|