Announcement Announcement Module
Collapse
No announcement yet.
SqlServerMaxValueIncrementer getNextKey method and the delete statement Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SqlServerMaxValueIncrementer getNextKey method and the delete statement

    Why does the SqlServerMaxValueIncrementer.getNextKey method perform a delete SQL statement? Does it serve any purpose for SQLServer?

    Specifically the following line of code (org.springframework/spring-jdbc/3.1.1.RELEASE, line 105):

    stmt.executeUpdate("delete from " + getIncrementerName() + " where " + getColumnName() + " < " + maxValue);

    As far as I can tell, the getNextKey method is performing the following:
    1. insert a row into table so the identity column generates the next key value
    2. select identity column value from table
    3. Delete the rows from table except last row

    I ask this because I occasionally see SQLServer deadlocks caused by the delete SQL statement when multiple jobs are running (not launched at the same time but are accessing the BATCH_STEP_EXECUTION_SEQ table roughly at the same time).
Working...
X