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 java.util.logging.Logger |
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.io.Serializable> |
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.io.Serializable |
nextPrimaryKey(java.lang.String table)
Return the next primary key for the specified table.
|
void |
reclaimKeys(java.io.Serializable[] 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 java.util.logging.Logger LOG
private static final java.lang.Integer[] PREFETCH_ARGS
private java.util.Queue<java.io.Serializable> 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 IdentityManager
persistence
- Persistence service object associated with identity manager.public java.io.Serializable nextPrimaryKey(java.lang.String table) throws PersistenceException
nextPrimaryKey
in interface IdentityManager
table
- 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.io.Serializable[] keys)
reclaimKeys
in interface IdentityManager
keys
- Keys for reuse.public void setIdentityPool(IdentityPool identityPool)
setIdentityPool
in interface IdentityPoolManager
identityPool
- Identity pool for use.