Class AbstractDataFieldMaxValueIncrementer
java.lang.Object
org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
- All Implemented Interfaces:
InitializingBean
,DataFieldMaxValueIncrementer
- Direct Known Subclasses:
AbstractColumnMaxValueIncrementer
,AbstractSequenceMaxValueIncrementer
public abstract class AbstractDataFieldMaxValueIncrementer
extends Object
implements DataFieldMaxValueIncrementer, 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 Summary
Modifier and TypeFieldDescriptionprotected int
The length to which a string result should be pre-pended with zeroes. -
Constructor Summary
ConstructorDescriptionDefault constructor for bean property style usage.AbstractDataFieldMaxValueIncrementer
(DataSource dataSource, String incrementerName) Convenience constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.Return the data source to retrieve the value from.Return the name of the sequence/table.protected abstract long
Determine the next key to use, as a long.int
Return the padding length for String values.int
Increment the data store field's max value as int.long
Increment the data store field's max value as long.Increment the data store field's max value as String.void
setDataSource
(DataSource dataSource) Set the data source to retrieve the value from.void
setIncrementerName
(String incrementerName) Set the name of the sequence/table.void
setPaddingLength
(int paddingLength) Set the padding length, i.e.
-
Field Details
-
paddingLength
protected int paddingLengthThe length to which a string result should be pre-pended with zeroes.
-
-
Constructor Details
-
AbstractDataFieldMaxValueIncrementer
public AbstractDataFieldMaxValueIncrementer()Default constructor for bean property style usage. -
AbstractDataFieldMaxValueIncrementer
Convenience constructor.- Parameters:
dataSource
- the DataSource to useincrementerName
- the name of the sequence/table to use
-
-
Method Details
-
setDataSource
Set the data source to retrieve the value from. -
getDataSource
Return the data source to retrieve the value from. -
setIncrementerName
Set the name of the sequence/table. -
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()Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
nextIntValue
Description copied from interface:DataFieldMaxValueIncrementer
Increment the data store field's max value as int.- Specified by:
nextIntValue
in interfaceDataFieldMaxValueIncrementer
- Returns:
- int next data store value such as max + 1
- Throws:
DataAccessException
- in case of errors
-
nextLongValue
Description copied from interface:DataFieldMaxValueIncrementer
Increment the data store field's max value as long.- Specified by:
nextLongValue
in interfaceDataFieldMaxValueIncrementer
- Returns:
- int next data store value such as max + 1
- Throws:
DataAccessException
- in case of errors
-
nextStringValue
Description copied from interface:DataFieldMaxValueIncrementer
Increment the data store field's max value as String.- Specified by:
nextStringValue
in interfaceDataFieldMaxValueIncrementer
- Returns:
- next data store value such as max + 1
- Throws:
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.
-