Class AbstractPreGenerateIdGenerator

java.lang.Object
org.seasar.doma.jdbc.id.AbstractIdGenerator
org.seasar.doma.jdbc.id.AbstractPreGenerateIdGenerator
All Implemented Interfaces:
IdGenerator
Direct Known Subclasses:
BuiltinSequenceIdGenerator, BuiltinTableIdGenerator

public abstract class AbstractPreGenerateIdGenerator extends AbstractIdGenerator
A generator that generates an identity value before an execution of insert.
  • Field Details

  • Constructor Details

    • AbstractPreGenerateIdGenerator

      public AbstractPreGenerateIdGenerator()
  • Method Details

    • setInitialValue

      public void setInitialValue(long initialValue)
      Sets the initial value.
      Parameters:
      initialValue - the initial value
    • setAllocationSize

      public void setAllocationSize(long allocationSize)
      Sets the allocation size.
      Parameters:
      allocationSize - the allocation size
    • supportsBatch

      public boolean supportsBatch(IdGenerationConfig config)
      Description copied from interface: IdGenerator
      Whether this generator supports the batch insert.
      Parameters:
      config - the configuration
      Returns:
      true if this generator supports
    • supportsAutoGeneratedKeys

      public boolean supportsAutoGeneratedKeys(IdGenerationConfig config)
      Description copied from interface: IdGenerator
      Whether this generator supports Statement.getGeneratedKeys().
      Parameters:
      config - the configuration
      Returns:
      true if this generator supports
    • includesIdentityColumn

      public boolean includesIdentityColumn(IdGenerationConfig config)
      Description copied from interface: IdGenerator
      Whether this generator includes the identity column into SQL INSERT statements.
      Parameters:
      config - the configuration
      Returns:
      true if supported
    • includesIdentityColumn

      public boolean includesIdentityColumn(IdGenerationConfig config, Object idValue)
      Description copied from interface: IdGenerator
      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

      public Long generatePreInsert(IdGenerationConfig config)
      Description copied from interface: IdGenerator
      Generates the identity value before an insert.
      Parameters:
      config - the configuration
      Returns:
      the generated value or null if not supported
    • generateValuesPreInsert

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

      public Long generatePostInsert(IdGenerationConfig config, Statement statement)
      Description copied from interface: IdGenerator
      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
    • getIdContext

      Returns the identity context.
      Parameters:
      config - the configuration
      Returns:
      the identity context
    • getNewInitialValue

      protected abstract long getNewInitialValue(IdGenerationConfig config)
      Return the next initial value.
      Parameters:
      config - the configuration
      Returns:
      the new initial value
      Throws:
      JdbcException - if it fails to retrieve the next initial value.