spring-framework / org.springframework.jdbc.support.incrementer

Package org.springframework.jdbc.support.incrementer

Types

AbstractIdentityColumnMaxValueIncrementer

abstract class AbstractIdentityColumnMaxValueIncrementer : AbstractColumnMaxValueIncrementer

Abstract base class for DataFieldMaxValueIncrementer implementations which are based on identity columns in a sequence-like table.

DB2MainframeSequenceMaxValueIncrementer

open class DB2MainframeSequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given sequence on DB2/390 or DB2/400. Thanks to Jens Eickmeyer for the suggestion!

DB2SequenceMaxValueIncrementer

open class DB2SequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given sequence on DB2 UDB (for Unix and Windows). Thanks to Mark MacMahon for the suggestion!

DerbyMaxValueIncrementer

open class DerbyMaxValueIncrementer : AbstractIdentityColumnMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given Derby table with the equivalent of an auto-increment column. Note: If you use this class, your Derby key column should NOT be defined as an IDENTITY column, as the sequence table does the job.

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Derby requires an additional column to be used for the insert since it is impossible to insert a null into the identity column and have the value generated. This is solved by providing the name of a dummy column that also must be created in the sequence table.

Example:

create table tab (id int not null primary key, text varchar(100)); create table tab_sequence (value int generated always as identity, dummy char(1)); insert into tab_sequence (dummy) values(null);
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize. HINT: Since Derby supports the JDBC 3.0 getGeneratedKeys method, it is recommended to use IDENTITY columns directly in the tables and then utilizing a org.springframework.jdbc.support.KeyHolder when calling the with the update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) method of the org.springframework.jdbc.core.JdbcTemplate.

Thanks to Endre Stolsvik for the suggestion!

H2SequenceMaxValueIncrementer

open class H2SequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given H2 Database sequence.

HsqlMaxValueIncrementer

open class HsqlMaxValueIncrementer : AbstractIdentityColumnMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given HSQL table with the equivalent of an auto-increment column. Note: If you use this class, your HSQL key column should NOT be auto-increment, as the sequence table does the job.

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Example:

create table tab (id int not null primary key, text varchar(100)); create table tab_sequence (value identity); insert into tab_sequence values(0);
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize.

NOTE: HSQL now supports sequences and you should consider using them instead: HsqlSequenceMaxValueIncrementer

HsqlSequenceMaxValueIncrementer

open class HsqlSequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given HSQL sequence. Thanks to Guillaume Bilodeau for the suggestion!

NOTE: This is an alternative to using a regular table to support generating unique keys that was necessary in previous versions of HSQL.

MySQLMaxValueIncrementer

open class MySQLMaxValueIncrementer : AbstractColumnMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given MySQL table with the equivalent of an auto-increment column. Note: If you use this class, your MySQL key column should NOT be auto-increment, as the sequence table does the job.

The sequence is kept in a table; there should be one sequence table per table that needs an auto-generated key. The storage engine used by the sequence table can be MYISAM or INNODB since the sequences are allocated using a separate connection without being affected by any other transactions that might be in progress.

Example:

create table tab (id int unsigned not null primary key, text varchar(100)); create table tab_sequence (value int not null); insert into tab_sequence values(0);
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize.

It is possible to avoid acquiring a new connection for the incrementer by setting the "useNewConnection" property to false. In this case you MUST use a non-transactional storage engine like MYISAM when defining the incrementer table.

OracleSequenceMaxValueIncrementer

open class OracleSequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given Oracle sequence.

PostgreSQLSequenceMaxValueIncrementer

open class PostgreSQLSequenceMaxValueIncrementer : AbstractSequenceMaxValueIncrementer

DataFieldMaxValueIncrementer that retrieves the next value of a given PostgreSQL sequence. Thanks to Tomislav Urban for the suggestion!

SqlServerMaxValueIncrementer

open class SqlServerMaxValueIncrementer : AbstractIdentityColumnMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given SQL Server table with the equivalent of an auto-increment column. Note: If you use this class, your table key column should NOT be defined as an IDENTITY column, as the sequence table does the job.

This class is intended to be used with Microsoft SQL Server.

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Example:

create table tab (id int not null primary key, text varchar(100)) create table tab_sequence (id bigint identity) insert into tab_sequence default values
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize. HINT: Since Microsoft SQL Server supports the JDBC 3.0 getGeneratedKeys method, it is recommended to use IDENTITY columns directly in the tables and then using a org.springframework.jdbc.core.simple.SimpleJdbcInsert or utilizing a org.springframework.jdbc.support.KeyHolder when calling the with the update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) method of the org.springframework.jdbc.core.JdbcTemplate.

Thanks to Preben Nilsson for the suggestion!

SybaseAnywhereMaxValueIncrementer

open class SybaseAnywhereMaxValueIncrementer : SybaseMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given Sybase SQL Anywhere table with the equivalent of an auto-increment column. Note: If you use this class, your table key column should NOT be defined as an IDENTITY column, as the sequence table does the job.

This class is intended to be used with Sybase Anywhere.

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Example:

create table tab (id int not null primary key, text varchar(100)) create table tab_sequence (id bigint identity) insert into tab_sequence values(DEFAULT)
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize. HINT: Since Sybase Anywhere supports the JDBC 3.0 getGeneratedKeys method, it is recommended to use IDENTITY columns directly in the tables and then using a org.springframework.jdbc.core.simple.SimpleJdbcInsert or utilizing a org.springframework.jdbc.support.KeyHolder when calling the with the update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) method of the org.springframework.jdbc.core.JdbcTemplate.

Thanks to Tarald Saxi Stormark for the suggestion!

SybaseMaxValueIncrementer

open class SybaseMaxValueIncrementer : AbstractIdentityColumnMaxValueIncrementer

DataFieldMaxValueIncrementer that increments the maximum value of a given Sybase table with the equivalent of an auto-increment column. Note: If you use this class, your table key column should NOT be defined as an IDENTITY column, as the sequence table does the job.

This class is intended to be used with Sybase Adaptive Server.

The sequence is kept in a table. There should be one sequence table per table that needs an auto-generated key.

Example:

create table tab (id int not null primary key, text varchar(100)) create table tab_sequence (id bigint identity) insert into tab_sequence values()
If "cacheSize" is set, the intermediate values are served without querying the database. If the server or your application is stopped or crashes or a transaction is rolled back, the unused values will never be served. The maximum hole size in numbering is consequently the value of cacheSize. HINT: Since Sybase supports the JDBC 3.0 getGeneratedKeys method, it is recommended to use IDENTITY columns directly in the tables and then using a org.springframework.jdbc.core.simple.SimpleJdbcInsert or utilizing a org.springframework.jdbc.support.KeyHolder when calling the with the update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) method of the org.springframework.jdbc.core.JdbcTemplate.

Thanks to Yinwei Liu for the suggestion!