Class AbstractDataFieldMaxValueIncrementer

java.lang.Object
org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, DataFieldMaxValueIncrementer
Direct Known Subclasses:
AbstractColumnMaxValueIncrementer, AbstractSequenceMaxValueIncrementer

public abstract class AbstractDataFieldMaxValueIncrementer extends Object implements DataFieldMaxValueIncrementer, org.springframework.beans.factory.InitializingBean
Base implementation of DataFieldMaxValueIncrementer that delegates to a single getNextKey() template method that returns a long. Uses longs for String values, padding with zeroes if required.
Author:
Dmitriy Kopylenko, Juergen Hoeller, Jean-Pierre Pawlak, Juergen Hoeller
  • Field Details

    • paddingLength

      protected int paddingLength
      The length to which a string result should be pre-pended with zeroes.
  • Constructor Details

    • AbstractDataFieldMaxValueIncrementer

      public AbstractDataFieldMaxValueIncrementer()
      Default constructor for bean property style usage.
      See Also:
    • AbstractDataFieldMaxValueIncrementer

      public AbstractDataFieldMaxValueIncrementer(DataSource dataSource, String incrementerName)
      Convenience constructor.
      Parameters:
      dataSource - the DataSource to use
      incrementerName - the name of the sequence/table to use
  • Method Details

    • setDataSource

      public void setDataSource(DataSource dataSource)
      Set the data source to retrieve the value from.
    • getDataSource

      public DataSource getDataSource()
      Return the data source to retrieve the value from.
    • setIncrementerName

      public void setIncrementerName(String incrementerName)
      Set the name of the sequence/table.
    • getIncrementerName

      public String getIncrementerName()
      Return the name of the sequence/table.
    • setPaddingLength

      public void setPaddingLength(int paddingLength)
      Set the padding length, i.e. the length to which a string result should be pre-pended with zeroes.
    • getPaddingLength

      public int getPaddingLength()
      Return the padding length for String values.
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • nextIntValue

      public int nextIntValue() throws org.springframework.dao.DataAccessException
      Description copied from interface: DataFieldMaxValueIncrementer
      Increment the data store field's max value as int.
      Specified by:
      nextIntValue in interface DataFieldMaxValueIncrementer
      Returns:
      int next data store value such as max + 1
      Throws:
      org.springframework.dao.DataAccessException - in case of errors
    • nextLongValue

      public long nextLongValue() throws org.springframework.dao.DataAccessException
      Description copied from interface: DataFieldMaxValueIncrementer
      Increment the data store field's max value as long.
      Specified by:
      nextLongValue in interface DataFieldMaxValueIncrementer
      Returns:
      int next data store value such as max + 1
      Throws:
      org.springframework.dao.DataAccessException - in case of errors
    • nextStringValue

      public String nextStringValue() throws org.springframework.dao.DataAccessException
      Description copied from interface: DataFieldMaxValueIncrementer
      Increment the data store field's max value as String.
      Specified by:
      nextStringValue in interface DataFieldMaxValueIncrementer
      Returns:
      next data store value such as max + 1
      Throws:
      org.springframework.dao.DataAccessException - in case of errors
    • getNextKey

      protected abstract long getNextKey()
      Determine the next key to use, as a long.
      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.