Package org.springframework.jdbc.support.incrementer

# Class AbstractSequenceMaxValueIncrementer

java.lang.Object
org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer
org.springframework.jdbc.support.incrementer.AbstractSequenceMaxValueIncrementer

All Implemented Interfaces:
  `org.springframework.beans.factory.InitializingBean`, `DataFieldMaxValueIncrementer`

Direct Known Subclasses:
  `Db2LuwMaxValueIncrementer`, `Db2MainframeMaxValueIncrementer`, `H2SequenceMaxValueIncrementer`, `HanaSequenceMaxValueIncrementer`, `HsqlSequenceMaxValueIncrementer`, `MariaDBSequenceMaxValueIncrementer`, `OracleSequenceMaxValueIncrementer`, `PostgresSequenceMaxValueIncrementer`, `SqlServerSequenceMaxValueIncrementer`

public abstract class AbstractSequenceMaxValueIncrementer extends AbstractDataFieldMaxValueIncrementer
Abstract base class for `DataFieldMaxValueIncrementer` implementations that use a database sequence. Subclasses need to provide the database-specific SQL to use.

Since:
  26.02.2004
Author:
  Juergen Hoeller
See Also:
  - `getSequenceQuery()`

## Field Summary

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

`paddingLength`

## Constructor Summary

Constructors
Constructor
Description
`AbstractSequenceMaxValueIncrementer()`
Default constructor for bean property style usage.
`AbstractSequenceMaxValueIncrementer(DataSource dataSource, String incrementerName)`
Convenience constructor.

## Method Summary

Modifier and Type
Method
Description
`protected long`
`getNextKey()`
Executes the SQL as specified by `getSequenceQuery()`.
`protected abstract String`
`getSequenceQuery()`
Return the database-specific query to use for retrieving a sequence value.

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

`afterPropertiesSet, 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 Details

### AbstractSequenceMaxValueIncrementer

public AbstractSequenceMaxValueIncrementer()
Default constructor for bean property style usage.

See Also:
  - `AbstractDataFieldMaxValueIncrementer.setDataSource(javax.sql.DataSource)`
  - `AbstractDataFieldMaxValueIncrementer.setIncrementerName(java.lang.String)`

### AbstractSequenceMaxValueIncrementer

public AbstractSequenceMaxValueIncrementer(DataSource dataSource, String incrementerName)
Convenience constructor.

Parameters:
  `dataSource` - the DataSource to use
  `incrementerName` - the name of the sequence/table to use

## Method Details

### getNextKey

protected long getNextKey() throws org.springframework.dao.DataAccessException
Executes the SQL as specified by `getSequenceQuery()`.

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:
  `org.springframework.dao.DataAccessException`

### getSequenceQuery

protected abstract String getSequenceQuery()
Return the database-specific query to use for retrieving a sequence value.

The provided SQL is supposed to result in a single row with a single column that allows for extracting a `long` value.