public class IdentityValue extends IdGenerator
GenerationType.IDENTITY
.Modifier and Type | Field and Description |
---|---|
private GeneratorColumn |
column |
private GeneratorContext |
context |
private long |
currentValue |
private boolean |
needsAlignment |
private GeneratorTable |
table |
Constructor and Description |
---|
IdentityValue(GeneratorContext context,
GeneratorTable table,
GeneratorColumn column) |
Modifier and Type | Method and Description |
---|---|
void |
addNextValue(TableStatement statement,
GeneratorColumn tableColumn,
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.
|
long |
getCurrentValue()
The last value returned by
IdGenerator.createNextValue(Class) . |
ColumnExpression |
getExpression(GeneratorTable entityTable,
GeneratorColumn targetColumn,
Number targetId,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
boolean |
isPostIncrement()
Indicates that
IdGenerator.createNextValue(Class) should be called after the entity was written - as the value is
not available before. |
void |
setCurrentValue(long currentValue)
Sets a new start value.
|
createNextValue, createPreInsertStatements, derive
private final GeneratorContext context
private final GeneratorTable table
private final GeneratorColumn column
private long currentValue
private boolean needsAlignment
@ConstructorProperties(value={"context","table","column"}) @Generated(value="lombok") public IdentityValue(GeneratorContext context, GeneratorTable table, GeneratorColumn column)
public void addNextValue(TableStatement statement, GeneratorColumn tableColumn, Number value)
IdGenerator
addNextValue
in class IdGenerator
statement
- the current insert statementtableColumn
- 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
IdGenerator
currentValue + 1
.alignNextValue
in class IdGenerator
writer
- the target of the created statementsIOException
- if the writer throws onepublic long createNextValue()
IdGenerator
createNextValue
in class IdGenerator
public ColumnExpression getExpression(GeneratorTable entityTable, GeneratorColumn targetColumn, Number targetId, boolean whereExpression)
IdGenerator
getExpression
in class IdGenerator
entityTable
- the main table of the entitytargetColumn
- 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()
IdGenerator
IdGenerator.createNextValue(Class)
should be called after the entity was written - as the value is
not available before.isPostIncrement
in class IdGenerator
true
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)
IdGenerator
setCurrentValue
in class IdGenerator
currentValue
- the current value - most likely as extracted from the target database@Generated(value="lombok") public long getCurrentValue()
IdGenerator
IdGenerator.createNextValue(Class)
.getCurrentValue
in class IdGenerator
Copyright © 2022 fastnate.org. All rights reserved.