Class ObjectId
- All Implemented Interfaces:
IdSource
IdSource to create unique object IDs.
Only used if the backend does not support sequences, or if configured explicitly via table:<name>.
The counter is kept in a table with a single row and column id.
The first ID requested within a transaction increments the counter in the database, which locks the row until the end of the transaction. Further IDs of the same transaction are counted in memory only, and the final value is written once at the end of the transaction (via a pre-commit). IDs requested from within a pre-commit are written immediately, since the final update may already have been executed by then. As a consequence, the database serializes the transactions of all sessions allocating IDs from the same table.
The counting state belongs to the transaction (it is kept as a transaction property of the session), so a single instance can safely be shared by all sessions.
- Author:
- harald
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StatementKeycreateStatementKey(StatementId statementId) Creates the statement key.
The key includes the table name, since id sources on different tables must not share their statements.static ObjectIdGets 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
-
Constructor Details
-
ObjectId
-
-
Method Details
-
get
-
isLockFree
public boolean isLockFree()Description copied from interface:IdSourceReturns whether retrieving an id is a lock-free operation.- Returns:
- true if lock-free
-
nextId
-
createStatementKey
Creates the statement key.
The key includes the table name, since id sources on different tables must not share their statements.- Parameters:
statementId- the statement id- Returns:
- the statement key
-