public class ObjectSequenceId extends AbstractIdSource
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.
The creation of the sequence is backend-specific. For example, postgres expects:
CREATE SEQUENCE object_sequence_id;
| Modifier and Type | Field and Description |
|---|---|
static int |
GLOBAL_MULTIPLIER
Default global multiplier to allow application-specific offsets.
|
static int |
SEQUENCE_MULTIPLIER
Default sequence multiplier.
|
| Modifier and Type | Method and Description |
|---|---|
static ObjectSequenceId |
get(String name)
Gets a sequence id source.
Id sources are unique by name. |
static ObjectSequenceId |
get(String name,
int sequenceMultiplier,
int globalMultiplier)
Gets a sequence id source.
Id sources are unique by name. |
boolean |
isLockFree()
Returns whether retrieving an id is a lock-free operation.
|
long |
nextId(Db db)
Get the next unique ID.
|
assertDbNotRemote, assertOneRowAffected, getName, toStringpublic static final int GLOBAL_MULTIPLIER
public static final int SEQUENCE_MULTIPLIER
public static ObjectSequenceId get(String name, int sequenceMultiplier, int globalMultiplier)
name - the unique sequence namesequenceMultiplier - the sequence multiplierglobalMultiplier - the global multiplierpublic static ObjectSequenceId get(String name)
name - the unique sequence namepublic boolean isLockFree()
IdSourceCopyright © 2016 Krake Softwaretechnik. All rights reserved.