public class SequenceIdGenerator extends IdGenerator
SequenceGenerator.| Constructor and Description |
|---|
SequenceIdGenerator(javax.persistence.SequenceGenerator generator,
GeneratorDialect dialect,
boolean relativeIds)
Creates a new instance of
SequenceIdGenerator. |
| Modifier and Type | Method and Description |
|---|---|
void |
addNextValue(TableStatement statement,
GeneratorColumn column,
Number value)
Adds the generated value to the given statement.
|
void |
alignNextValue(StatementsWriter writer)
Creates all statements that are necessary to set the next value created from the database is
currentValue + 1. |
long |
createNextValue()
Resolves the next value of this generator.
|
void |
createPreInsertStatements(StatementsWriter writer)
Creates the statements that are needed in the output before
IdGenerator.addNextValue(TableStatement, GeneratorColumn, Number). |
int |
getAllocationSize()
The amount to increment by when allocating sequence numbers from the sequence.
|
String |
getCatalog()
The (optional) catalog that contains the schema of the sequence.
|
long |
getCurrentValue()
The last value returned by
IdGenerator.createNextValue(Class). |
GeneratorDialect |
getDialect()
The current database dialect.
|
ColumnExpression |
getExpression(GeneratorTable entityTable,
GeneratorColumn column,
Number targetId,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
long |
getInitialValue()
The value from which the sequence object is to start generating.
|
String |
getQualifiedName()
The fully qualfied name of the sequence, including the optional catalog and schema name.
|
String |
getSchema()
The (optional) schema that contains the sequence.
|
String |
getSequenceName()
The name of the sequence.
|
boolean |
isPostIncrement()
Indicates that
IdGenerator.createNextValue(Class) should be called after the entity was written - as the value is
not available before. |
boolean |
isRelativeIds()
Indicates that the sequence is used when referencing existing IDs, instead of absolute IDs.
|
void |
setCurrentValue(long currentValue)
Sets a new start value.
|
createNextValue, derivepublic SequenceIdGenerator(javax.persistence.SequenceGenerator generator,
GeneratorDialect dialect,
boolean relativeIds)
SequenceIdGenerator.generator - the annotation that contains our settingsdialect - the current database dialectrelativeIds - indicates that the sequence is always used, instead of absolute IDspublic void addNextValue(TableStatement statement, GeneratorColumn column, Number value)
IdGeneratoraddNextValue in class IdGeneratorstatement - the current insert statementcolumn - the ID column of the current tablevalue - the current value of the column, previously generated with IdGenerator.createNextValue()public void alignNextValue(StatementsWriter writer) throws IOException
IdGeneratorcurrentValue + 1.alignNextValue in class IdGeneratorwriter - the target of the created statementsIOException - if the writer throws onepublic long createNextValue()
IdGeneratorcreateNextValue in class IdGeneratorpublic void createPreInsertStatements(StatementsWriter writer) throws IOException
IdGeneratorIdGenerator.addNextValue(TableStatement, GeneratorColumn, Number).createPreInsertStatements in class IdGeneratorwriter - target for the created statementsIOException - if the writer throws onepublic long getCurrentValue()
IdGeneratorIdGenerator.createNextValue(Class).getCurrentValue in class IdGeneratorpublic ColumnExpression getExpression(GeneratorTable entityTable, GeneratorColumn column, Number targetId, boolean whereExpression)
IdGeneratorgetExpression in class IdGeneratorentityTable - the main table of the entitycolumn - the name of the column of the IDtargetId - the current value of the IDwhereExpression - indicates if this expression is needed for a "SELECT ... WHERE ..." - some dialects behave differently
in this situationpublic boolean isPostIncrement()
IdGeneratorIdGenerator.createNextValue(Class) should be called after the entity was written - as the value is
not available before.isPostIncrement in class IdGeneratortrue if the database increments the value _after_ the insert statement was executed, true
if it is incremented before or during the executionpublic void setCurrentValue(long currentValue)
IdGeneratorsetCurrentValue in class IdGeneratorcurrentValue - the current value - most likely as extracted from the target database@Generated(value="lombok") public GeneratorDialect getDialect()
@Generated(value="lombok") public String getCatalog()
@Generated(value="lombok") public String getSchema()
@Generated(value="lombok") public String getSequenceName()
@Generated(value="lombok") public String getQualifiedName()
@Generated(value="lombok") public boolean isRelativeIds()
@Generated(value="lombok") public int getAllocationSize()
@Generated(value="lombok") public long getInitialValue()
Copyright © 2020 fastnate.org. All rights reserved.