java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.SequenceConf

public class SequenceConf extends Object
A configuration class for managing and providing sequences of IDs in a Bibernate application. This class is designed to handle the generation and allocation of unique IDs using a queue-based approach. The sequence configuration includes parameters such as name, initial value, and allocation size. The default initial value and allocation size are set to 1, and the default sequence template is used for generating sequence names.

The class provides methods to retrieve the next ID from the sequence and set the next portion of IDs based on the current ID. The queue-based approach allows efficient and controlled allocation of IDs for entities in the application.

Note: The sequence name is typically constructed using the default sequence template, where the placeholders are replaced with the table name and column name.

Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • ids

      private Queue<Long> ids
      The queue to store and manage generated IDs.
    • DEFAULT_INITIAL_VALUE

      private static final int DEFAULT_INITIAL_VALUE
      The default initial value for the sequence.
      See Also:
    • DEFAULT_ALLOCATION_SIZE

      private static final int DEFAULT_ALLOCATION_SIZE
      The default allocation size for the sequence.
      See Also:
    • DEFAULT_SEQ_TEMPLATE

      public static final String DEFAULT_SEQ_TEMPLATE
      The default sequence template for generating sequence names. It includes placeholders for table name and column name.
      See Also:
    • name

      private final String name
      The name of the sequence.
    • initialValue

      private final int initialValue
      The initial value for the sequence.
    • allocationSize

      private final int allocationSize
      The allocation size for the sequence.
  • Constructor Details

    • SequenceConf

      public SequenceConf(String name)
      Constructs a new SequenceConf with the given name, using default initial value and allocation size.
      Parameters:
      name - the name of the sequence
  • Method Details

    • getNextId

      public Long getNextId()
      Retrieves the next ID from the sequence.
      Returns:
      the next ID
    • setNextPortionOfIds

      public void setNextPortionOfIds(Long currentId)
      Sets the next portion of IDs in the sequence based on the current ID.
      Parameters:
      currentId - the current ID