Java/Spring JDBC: Batch Insert into 2 Tables: Obtain FK ID from 1st Batch Insert Required for 2nd Table
问题 I'm using jdbcTemplate to Batch-Insert into 2 tables. The 1st table is easy, and has an ID . The 2nd table has an FK Reference USER_ID which I need to obtain from Table 1 before inserting. Suppose I have this: Main Java Code (here I split up into batches <= 1000) for(int i = 0; i < totalEntries.size(); i++) { // Add to Batch-Insert List; if list size ready for batch-insert, or if at the end, batch-persist & clear list batchInsert.add(user); if (batchInsert.size() == 1000 || i == totalEntries