Module io.ebean.api

Class SequenceIdGenerator

java.lang.Object
io.ebean.config.dbplatform.SequenceIdGenerator
All Implemented Interfaces:
PlatformIdGenerator
Direct Known Subclasses:
SequenceBatchIdGenerator, SequenceStepIdGenerator

public abstract class SequenceIdGenerator extends Object implements PlatformIdGenerator
Database sequence based IdGenerator.
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • seqName

      protected final String seqName
    • dataSource

      protected final DataSource dataSource
    • backgroundExecutor

      protected final BackgroundExecutor backgroundExecutor
    • idList

      protected final NavigableSet<Long> idList
    • allocationSize

      protected final int allocationSize
    • currentlyBackgroundLoading

      protected AtomicBoolean currentlyBackgroundLoading
  • Constructor Details

    • SequenceIdGenerator

      protected SequenceIdGenerator(BackgroundExecutor be, DataSource ds, String seqName, int allocationSize)
      Construct given a dataSource and sql to return the next sequence value.
  • Method Details

    • getSql

      public abstract String getSql(int batchSize)
    • getName

      public String getName()
      Returns the sequence name.
      Specified by:
      getName in interface PlatformIdGenerator
    • isDbSequence

      public boolean isDbSequence()
      Returns true.
      Specified by:
      isDbSequence in interface PlatformIdGenerator
    • preAllocateIds

      public void preAllocateIds(int requestSize)
      If allocateSize is large load some sequences in a background thread.

      For example, when inserting a bean with a cascade on a OneToMany with many beans Ebean can call this to ensure .

      Specified by:
      preAllocateIds in interface PlatformIdGenerator
    • nextId

      public Object nextId(Transaction t)
      Return the next Id.

      If a Transaction has been passed in use the Connection from it.

      Specified by:
      nextId in interface PlatformIdGenerator
    • loadInBackground

      protected void loadInBackground(int requestSize)
      Load another batch of Id's using a background thread.
    • readIds

      protected abstract List<Long> readIds(ResultSet resultSet, int loadSize) throws SQLException
      Read the resultSet returning the list of Id values.
      Throws:
      SQLException
    • getMoreIds

      protected List<Long> getMoreIds(int requestSize)
      Get more Id's by executing a query and reading the Id's returned.