- All Known Subinterfaces:
IdentityIdGenerator,SequenceIdGenerator,TableIdGenerator
- All Known Implementing Classes:
AbstractIdGenerator,AbstractPreGenerateIdGenerator,BuiltinIdentityIdGenerator,BuiltinSequenceIdGenerator,BuiltinTableIdGenerator
public interface IdGenerator
An identity generator.
Either generatePreInsert(IdGenerationConfig) or generatePostInsert(IdGenerationConfig, Statement) must return non-null value.
The implementation class must have a public no-args constructor.
The implementation class must be thread safe.
-
Method Summary
Modifier and TypeMethodDescriptiongeneratePostInsert(IdGenerationConfig config, Statement statement) Generates the identity value after an insert.generatePreInsert(IdGenerationConfig config) Generates the identity value before an insert.generateValuesPostInsert(IdGenerationConfig config, Statement statement) generateValuesPreInsert(IdGenerationConfig config, int count) Returns the generation type.booleanDeprecated.default booleanincludesIdentityColumn(IdGenerationConfig config, Object idValue) Determines whether the identity column is included in the SQL INSERT statements based on the given configuration and identity value.booleanWhether this generator supportsStatement.getGeneratedKeys().booleansupportsBatch(IdGenerationConfig config) Whether this generator supports the batch insert.
-
Method Details
-
supportsBatch
Whether this generator supports the batch insert.- Parameters:
config- the configuration- Returns:
trueif this generator supports
-
supportsAutoGeneratedKeys
Whether this generator supportsStatement.getGeneratedKeys().- Parameters:
config- the configuration- Returns:
trueif this generator supports
-
includesIdentityColumn
Deprecated.Whether this generator includes the identity column into SQL INSERT statements.- Parameters:
config- the configuration- Returns:
trueif supported
-
includesIdentityColumn
Determines whether the identity column is included in the SQL INSERT statements based on the given configuration and identity value.The type of
idValuemust be one of the basic types. It must never be a domain class or an Optional type that wraps a basic type.- Parameters:
config- the configuration for identity generationidValue- an identity value; may be null- Returns:
trueif the identity column is included in the SQL INSERT statements, otherwisefalse
-
generatePreInsert
Generates the identity value before an insert.- Parameters:
config- the configuration- Returns:
- the generated value or
nullif not supported - Throws:
JdbcException- if the generation is failed
-
generateValuesPreInsert
-
generatePostInsert
Generates the identity value after an insert.- Parameters:
config- the configurationstatement- the SQL INSERT statement- Returns:
- the generated value or
nullif not supported - Throws:
JdbcException- if the generation is failed
-
generateValuesPostInsert
-
getGenerationType
GenerationType getGenerationType()Returns the generation type.- Returns:
- the generation type
-