public class MariaDbSequenceHandler extends SequenceHandler
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
Central Logger.
|
private java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> |
sequences
The list of sequences grouped by databases.
|
| Constructor and Description |
|---|
MariaDbSequenceHandler(java.lang.String ldbName)
The only constructor takes the name of the database as argument.
|
| Modifier and Type | Method and Description |
|---|---|
private static java.lang.Object |
executeSQL(java.lang.String sqlStmt,
Database db,
boolean select,
java.lang.Object... params)
Execute a SQL statement and optionally return the result as a single value.
|
protected boolean |
safeContains(java.lang.String seqName,
java.lang.String ldbName)
Test whether the database contains a sequence.
|
protected int64 |
safeGetCurrentValue(java.lang.String seqName,
java.lang.String ldbName)
Queries the current value of a sequence.
|
protected int64 |
safeGetNextValue(java.lang.String seqName,
java.lang.String ldbName)
Computes and returns the next value of a sequence.
|
protected void |
safeSetValue(java.lang.String seqName,
java.lang.String ldbName,
long newVal)
Initialize (reset) the current value of a sequence.
|
contains, getCurrentValue, getNextValue, getResultValue, setValueprivate static final CentralLogger LOG
private java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> sequences
public MariaDbSequenceHandler(java.lang.String ldbName)
ldbName - The database logical name on which this handler will work with.protected int64 safeGetCurrentValue(java.lang.String seqName, java.lang.String ldbName)
This method should be called only in a safe environment, where the database-level lock for access to sequences has already been acquired.
safeGetCurrentValue in class SequenceHandlerseqName - The name of the sequence.ldbName - The database to which the sequence belongs to. It is assumed it is not null and valid.protected int64 safeGetNextValue(java.lang.String seqName, java.lang.String ldbName)
This method should be called only in a safe environment, where the database-level lock for access to sequences has already been acquired.
safeGetNextValue in class SequenceHandlerseqName - The name of the sequence.ldbName - The database to which the sequence belongs to. It is assumed it is not null and valid.protected void safeSetValue(java.lang.String seqName,
java.lang.String ldbName,
long newVal)
This method should be called only in a safe environment, where the database-level lock for access to sequences has already been acquired.
safeSetValue in class SequenceHandlerseqName - The name of the sequence.ldbName - The database to which the sequence belongs to.
It is assumed it is not null and valid.newVal - The value the sequence will be reset to.protected boolean safeContains(java.lang.String seqName,
java.lang.String ldbName)
This method should be called only in a safe environment, where the database-level lock for access to sequences has already been acquired.
safeContains in class SequenceHandlerseqName - The name of the sequence.ldbName - The database to which the sequence belongs to. If is null then the first connected
database is assumed.true if the sequence is defined in the databaseprivate static java.lang.Object executeSQL(java.lang.String sqlStmt,
Database db,
boolean select,
java.lang.Object... params)
sqlStmt - The SQL statement to be executed.db - The Database on which the statement will be executed.select - Flags a SELECT statement. The statement will be executed as a query and the first result will
be returned as unique value.params - An optional set of parameters for the statement.null is the query provided an empty result set.
In case of not SELECT statements, the result is always null.