On Apr 23, 2006, at 1:21 PM, Borut Bolčina wrote:

If I understand you correctly, the above algorithm would create a statement DELETE FROM AUTO_PK_SUPPORT WHERE TABLE_NAME IN ('tableA', 'tableB', 'tableC')
but not, say, tableD, as it is already present (created before).

In my case this pkDeleteString would look like (empty table names)
DELETE FROM AUTO_PK_SUPPORT WHERE TABLE_NAME IN ('')
INSERT INTO AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('', 200)

Sorry, my first message and the correction that followed was a bit confusing. "DELETE FROM .." is not needed at all. You need to do a SELECT to see what's there, compare with the full entity list, and only insert the missing records.

Also see Mike's suggestion on how to figure out the right starting value. It may work as an alternative or an addition to the algorithm above.


One "workaround" I can think of is to do a SELECT on AUTO_PK_SUPPORT and if no error is thrown I must assume the table exists, so I skip generator.runGenerator(dataSource); altogether.

This is not generic enough as you may end up with missing records if you added a few new tables since the last run (so AUTO_PK_SUPPORT is there, but its contents are incomplete).

Andrus

Reply via email to