public final class SequenceIdentityManager extends java.lang.Object implements IdentityPoolManager
IdentityManager interface which uses a sequence (global to a
specific database) to produce 64-bit integer IDs which are unique across all records in that
database.
Current limitations:
Long.MAX_VALUE is not
handled at this time.
| Modifier and Type | Field and Description |
|---|---|
private IdentityPool |
identityPool
Identity pool used by this identity manager.
|
private static CentralLogger |
LOG
Logger
|
private java.lang.String |
nextKeySQL
SQL statement used to get next sequence value
|
private Persistence |
persistence
Persistence service object associated with this identity manager
|
private static java.lang.Integer[] |
PREFETCH_ARGS
Range arguments passed to prefetch SQL statement
|
private java.util.Queue<java.lang.Long> |
prefetched
Queue of prefetched results
|
private java.lang.String |
prefetchKeySQL
SQL statement used to prefetch multiple sequence values at once
|
| Constructor and Description |
|---|
SequenceIdentityManager()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Long |
nextPrimaryKey(java.lang.String table)
Return the next primary key for the specified table.
|
void |
reclaimKeys(java.lang.Long[] keys)
Inform the identity manager that the given primary keys can be reused.
|
void |
setIdentityPool(IdentityPool identityPool)
Sets identity pool which can be used by this identity manager.
|
void |
setPersistence(Persistence persistence)
Specify the database for the identity manager.
|
private static final CentralLogger LOG
private static final java.lang.Integer[] PREFETCH_ARGS
private java.util.Queue<java.lang.Long> prefetched
private IdentityPool identityPool
private Persistence persistence
private java.lang.String prefetchKeySQL
private java.lang.String nextKeySQL
public void setPersistence(Persistence persistence)
DefaultIdentityManager is initialized here - current
maximum IDs for each table are retrieved.setPersistence in interface IdentityManagerpersistence - Persistence service object associated with identity manager.public java.lang.Long nextPrimaryKey(java.lang.String table)
throws PersistenceException
nextPrimaryKey in interface IdentityManagertable - Table for which the next primary key will be returned.PersistenceException - if there is an error determining the next primary key ID.public void reclaimKeys(java.lang.Long[] keys)
reclaimKeys in interface IdentityManagerkeys - Keys for reuse.public void setIdentityPool(IdentityPool identityPool)
setIdentityPool in interface IdentityPoolManageridentityPool - Identity pool for use.