org.springframework.jdbc.support.incrementer

## Class AbstractIdentityColumnMaxValueIncrementer

- java.lang.Object
- - org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
  - - org.springframework.jdbc.support.incrementer.AbstractColumnMaxValueIncrementer
    - - org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer

- All Implemented Interfaces:
    InitializingBean, DataFieldMaxValueIncrementer
  Direct Known Subclasses:
    DerbyMaxValueIncrementer, HsqlMaxValueIncrementer, SqlServerMaxValueIncrementer, SybaseMaxValueIncrementer

      public abstract class AbstractIdentityColumnMaxValueIncrementer
      extends AbstractColumnMaxValueIncrementer

  Abstract base class for `DataFieldMaxValueIncrementer` implementations which are based on identity columns in a sequence-like table.
  Since:
    4.1.2
  Author:
    Juergen Hoeller, Thomas Risberg

- - ### Field Summary

    - ### Fields inherited from class org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer

      `paddingLength`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractIdentityColumnMaxValueIncrementer()` Default constructor for bean property style usage.
    `AbstractIdentityColumnMaxValueIncrementer(DataSource dataSource, String incrementerName, String columnName)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `getDeleteStatement(long[] values)` Statement to use to clean up "sequence" values.
    `protected abstract String` | `getIdentityStatement()` Statement to use to obtain the current identity value.
    `protected abstract String` | `getIncrementStatement()` Statement to use to increment the "sequence" value.
    `protected long` | `getNextKey()` Determine the next key to use, as a long.
    `boolean` | `isDeleteSpecificValues()` Return whether to delete the entire range below the current maximum key value (`false` - the default), or the specifically generated values (`true`).
    `void` | `setDeleteSpecificValues(boolean deleteSpecificValues)` Specify whether to delete the entire range below the current maximum key value (`false` - the default), or the specifically generated values (`true`).

    - ### Methods inherited from class org.springframework.jdbc.support.incrementer.AbstractColumnMaxValueIncrementer

      `afterPropertiesSet, getCacheSize, getColumnName, setCacheSize, setColumnName`

    - ### Methods inherited from class org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer

      `getDataSource, getIncrementerName, getPaddingLength, nextIntValue, nextLongValue, nextStringValue, setDataSource, setIncrementerName, setPaddingLength`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractIdentityColumnMaxValueIncrementer

          public AbstractIdentityColumnMaxValueIncrementer()

      Default constructor for bean property style usage.
      See Also:
        `AbstractDataFieldMaxValueIncrementer.setDataSource(javax.sql.DataSource)`, `AbstractDataFieldMaxValueIncrementer.setIncrementerName(java.lang.String)`, `AbstractColumnMaxValueIncrementer.setColumnName(java.lang.String)`

    - #### AbstractIdentityColumnMaxValueIncrementer

          public AbstractIdentityColumnMaxValueIncrementer(DataSource dataSource,
                                                           String incrementerName,
                                                           String columnName)

  - ### Method Detail

    - #### setDeleteSpecificValues

          public void setDeleteSpecificValues(boolean deleteSpecificValues)

      Specify whether to delete the entire range below the current maximum key value (`false` - the default), or the specifically generated values (`true`). The former mode will use a where range clause whereas the latter will use an in clause starting with the lowest value minus 1, just preserving the maximum value.

    - #### isDeleteSpecificValues

          public boolean isDeleteSpecificValues()

      Return whether to delete the entire range below the current maximum key value (`false` - the default), or the specifically generated values (`true`).

    - #### getNextKey

          protected long getNextKey()
                             throws DataAccessException

      Description copied from class: `AbstractDataFieldMaxValueIncrementer`
      Determine the next key to use, as a long.
      Specified by:
        `getNextKey` in class `AbstractDataFieldMaxValueIncrementer`
      Returns:
        the key to use as a long. It will eventually be converted later in another format by the public concrete methods of this class.
      Throws:
        `DataAccessException`

    - #### getIncrementStatement

          protected abstract String getIncrementStatement()

      Statement to use to increment the "sequence" value.
      Returns:
        the SQL statement to use

    - #### getIdentityStatement

          protected abstract String getIdentityStatement()

      Statement to use to obtain the current identity value.
      Returns:
        the SQL statement to use

    - #### getDeleteStatement

          protected String getDeleteStatement(long[] values)

      Statement to use to clean up "sequence" values.

      The default implementation either deletes the entire range below the current maximum value, or the specifically generated values (starting with the lowest minus 1, just preserving the maximum value) - according to the `isDeleteSpecificValues()` setting.

      Parameters:
        `values` - the currently generated key values (the number of values corresponds to `AbstractColumnMaxValueIncrementer.getCacheSize()`)
      Returns:
        the SQL statement to use