Class ObjectSequenceId
java.lang.Object
org.tentackle.dbms.AbstractIdSource
org.tentackle.dbms.ObjectSequenceId
- All Implemented Interfaces:
IdSource
An
IdSource to create unique object IDs from a database sequence.
To reduce the number of roundtrips, the sequence is multiplied by a sequence-multiplier and a counter just incremented within that range.
There is one instance per sequence name, shared by all sessions. The range taken from the sequence is kept per database, i.e., per backend identity, so an application connected to several databases never hands out ids reserved in the sequence of another database.
The creation of the sequence is backend-specific. For example, Postgres expects:
CREATE SEQUENCE object_sequence_id;
- Author:
- harald
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault name of the object sequence id.static final intDefault global multiplier to allow application-specific offsets.static final intDefault sequence multiplier. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectSequenceIdGets a sequence id source.
ID sources are unique by name.static ObjectSequenceIdGets a sequence id source.
ID sources are unique by name.booleanReturns whether retrieving an id is a lock-free operation.longGets the next unique ID.Methods inherited from class AbstractIdSource
assertDbNotRemote, assertOneRowAffected, getName, toString
-
Field Details
-
DEFAULT_NAME
-
GLOBAL_MULTIPLIER
public static final int GLOBAL_MULTIPLIERDefault global multiplier to allow application-specific offsets.- See Also:
-
SEQUENCE_MULTIPLIER
public static final int SEQUENCE_MULTIPLIERDefault sequence multiplier.- See Also:
-
-
Method Details
-
get
Gets a sequence id source.
ID sources are unique by name.- Parameters:
name- the unique sequence namesequenceMultiplier- the sequence multiplierglobalMultiplier- the global multiplier- Returns:
- the ID source
-
get
Gets a sequence id source.
ID sources are unique by name.- Parameters:
name- the unique sequence name- Returns:
- the ID source
-
isLockFree
public boolean isLockFree()Description copied from interface:IdSourceReturns whether retrieving an id is a lock-free operation.- Returns:
- true if lock-free
-
nextId
-