I am using Spring and JDBCTemplate.
The scenario is a CUSTOMER table and ORDERS table – parent-child relationship.
I want to do an insert (for example 1 customer and 5 orders) – but I am unsure how you programmatically insert a row in the CUSTOMER table (some how get hold of the Oracle generated unique id), and then insert the corresponding 5 rows in the child table, ORDERS, with the unique id created by the customer insert. This unique id obviously maintains a relationship between a customer and their orders.
Any help much appreciated.
PS – Code with example SQL on how this is done in Spring Framework would be fantastic – something fairly rough just to give me the basic idea.
Check the update method in JDBCTemplate whcih takes a KeyHolder object. After execution that Keyholder objects contains the generated key.
The Spring documentation has an example of usage here.