Class SequenceConf
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.jdbc.identity.SequenceConf
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 Summary
Modifier and TypeFieldDescriptionprivate final int
The allocation size for the sequence.private static final int
The default allocation size for the sequence.private static final int
The default initial value for the sequence.static final String
The default sequence template for generating sequence names.The queue to store and manage generated IDs.private final int
The initial value for the sequence.private final String
The name of the sequence. -
Constructor Summary
ConstructorDescriptionSequenceConf
(String name) Constructs a new SequenceConf with the given name, using default initial value and allocation size. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the next ID from the sequence.void
setNextPortionOfIds
(Long currentId) Sets the next portion of IDs in the sequence based on the current ID.
-
Field Details
-
ids
The queue to store and manage generated IDs. -
DEFAULT_INITIAL_VALUE
private static final int DEFAULT_INITIAL_VALUEThe default initial value for the sequence.- See Also:
-
DEFAULT_ALLOCATION_SIZE
private static final int DEFAULT_ALLOCATION_SIZEThe default allocation size for the sequence.- See Also:
-
DEFAULT_SEQ_TEMPLATE
The default sequence template for generating sequence names. It includes placeholders for table name and column name.- See Also:
-
name
The name of the sequence. -
initialValue
private final int initialValueThe initial value for the sequence. -
allocationSize
private final int allocationSizeThe allocation size for the sequence.
-
-
Constructor Details
-
SequenceConf
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
Retrieves the next ID from the sequence.- Returns:
- the next ID
-
setNextPortionOfIds
Sets the next portion of IDs in the sequence based on the current ID.- Parameters:
currentId
- the current ID
-