public class WGSequence
extends java.lang.Object
increment()
.
Each sequence is identified by a name that may consist of alphanumeric characters plus the characters _.-:$.
The state of the sequence is stored inside the database and is therefor persistent and also restorable from database backups.
It is guaranteed that the sequence service is consistent across threads and WGA server cluster nodes, returning one unique value only one time on the whole system.
Instances of this object can be used across multiple database sessions, but are only usable while a database session is open.
Sequences may be initialized with a custom start value - the first value to be retrieved by increment()
- using initialize(long)
, but do not need to. The default start value is 1, which is implictly used when calling increment()
on an uninitialized sequence.Modifier and Type | Method and Description |
---|---|
long |
getLastIncrementValue()
Returns the last value that was returned from this sequence on incrementation.
|
long |
increment()
Increments the sequence and returns a new unique number
|
boolean |
initialize(long startValue)
Initialize a sequence with the given start value if it is not already initialized.
|
boolean |
initialize(long startValue,
boolean forceInit)
Initialize a sequence with the given start value if it is not already initialized or argument forceInit is true.
|
boolean |
isInitialized()
Returns if the sequence is already initialized, either by calling
initialize(long) and/or by calling increment() . |
void |
remove()
Removes the sequence, deleting all initialisation and incrementation status
|
public boolean initialize(long startValue) throws WGAPIException
increment()
on an uninitialized sequence.startValue
- The start value of the sequence, i.e. the first value returned by the first call of increment()
WGAPIException
public boolean initialize(long startValue, boolean forceInit) throws WGAPIException
increment()
on an uninitialized sequence.startValue
- The start value of the sequence, i.e. the first value returned by the first call of increment()
forceInit
- Specify true if you want to reset the sequence to the given start value even if it was already initialized and may be in use.WGAPIException
public boolean isInitialized() throws WGAPIException
initialize(long)
and/or by calling increment()
.
This method may return false if the sequence was initialized via initialize(long)
with default start value 1, as this creates the standard starting point for uninitialized sequences.WGAPIException
public long increment() throws WGAPIException
WGAPIException
public void remove() throws WGAPIException
WGAPIException
public long getLastIncrementValue() throws WGAPIException
WGAPIException