Interface IdGenerator

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 Details

    • supportsBatch

      boolean supportsBatch(IdGenerationConfig config)
      Whether this generator supports the batch insert.
      Parameters:
      config - the configuration
      Returns:
      true if this generator supports
    • supportsAutoGeneratedKeys

      boolean supportsAutoGeneratedKeys(IdGenerationConfig config)
      Whether this generator supports Statement.getGeneratedKeys().
      Parameters:
      config - the configuration
      Returns:
      true if this generator supports
    • includesIdentityColumn

      @Deprecated boolean includesIdentityColumn(IdGenerationConfig config)
      Deprecated.
      Whether this generator includes the identity column into SQL INSERT statements.
      Parameters:
      config - the configuration
      Returns:
      true if supported
    • includesIdentityColumn

      default boolean includesIdentityColumn(IdGenerationConfig config, Object idValue)
      Determines whether the identity column is included in the SQL INSERT statements based on the given configuration and identity value.

      The type of idValue must 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 generation
      idValue - an identity value; may be null
      Returns:
      true if the identity column is included in the SQL INSERT statements, otherwise false
    • generatePreInsert

      Long generatePreInsert(IdGenerationConfig config)
      Generates the identity value before an insert.
      Parameters:
      config - the configuration
      Returns:
      the generated value or null if not supported
      Throws:
      JdbcException - if the generation is failed
    • generateValuesPreInsert

      default List<Long> generateValuesPreInsert(IdGenerationConfig config, int count)
    • generatePostInsert

      Long generatePostInsert(IdGenerationConfig config, Statement statement)
      Generates the identity value after an insert.
      Parameters:
      config - the configuration
      statement - the SQL INSERT statement
      Returns:
      the generated value or null if not supported
      Throws:
      JdbcException - if the generation is failed
    • generateValuesPostInsert

      default List<Long> generateValuesPostInsert(IdGenerationConfig config, Statement statement)
    • getGenerationType

      GenerationType getGenerationType()
      Returns the generation type.
      Returns:
      the generation type