public abstract class IdGenerator extends Object
GeneratedIdProperty
.Constructor and Description |
---|
IdGenerator() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addNextValue(TableStatement statement,
GeneratorColumn column,
Number nextValue)
Adds the generated value to the given statement.
|
abstract void |
alignNextValue(StatementsWriter writer)
Creates all statements that are necessary to set the next value created from the database is
currentValue + 1 . |
protected abstract long |
createNextValue()
Resolves the next value of this generator.
|
<N extends Number> |
createNextValue(Class<N> propertyClass)
Resolves the next value of this generator.
|
void |
createPreInsertStatements(StatementsWriter writer)
Creates the statements that are needed in the output before
addNextValue(TableStatement, GeneratorColumn, Number) . |
IdGenerator |
derive(GeneratorTable entityTable)
Some implementations (like the Hibernate table generator) create a different generator, depending on the table
name.
|
abstract long |
getCurrentValue()
The last value returned by
createNextValue(Class) . |
abstract ColumnExpression |
getExpression(GeneratorTable table,
GeneratorColumn column,
Number id,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
abstract boolean |
isPostIncrement()
Indicates that
createNextValue(Class) should be called after the entity was written - as the value is
not available before. |
abstract void |
setCurrentValue(long currentValue)
Sets a new start value.
|
public abstract void addNextValue(TableStatement statement, GeneratorColumn column, Number nextValue)
statement
- the current insert statementcolumn
- the ID column of the current tablenextValue
- the current value of the column, previously generated with createNextValue()
public abstract void alignNextValue(StatementsWriter writer) throws IOException
currentValue + 1
.writer
- the target of the created statementsIOException
- if the writer throws oneprotected abstract long createNextValue()
public <N extends Number> N createNextValue(Class<N> propertyClass)
propertyClass
- the type of the generated valuepublic void createPreInsertStatements(StatementsWriter writer) throws IOException
addNextValue(TableStatement, GeneratorColumn, Number)
.writer
- target for the created statementsIOException
- if the writer throws onepublic IdGenerator derive(GeneratorTable entityTable)
entityTable
- the current entity tablepublic abstract long getCurrentValue()
createNextValue(Class)
.public abstract ColumnExpression getExpression(GeneratorTable table, GeneratorColumn column, Number id, boolean whereExpression)
table
- the main table of the entitycolumn
- the name of the column of the IDid
- the current value of the IDwhereExpression
- indicates if this expression is needed for a "SELECT ... WHERE ..." - some dialects behave differently
in this situationpublic abstract boolean isPostIncrement()
createNextValue(Class)
should be called after the entity was written - as the value is
not available before.true
if the database increments the value _after_ the insert statement was executed, true
if it is incremented before or during the executionpublic abstract void setCurrentValue(long currentValue)
currentValue
- the current value - most likely as extracted from the target databaseCopyright © 2022 fastnate.org. All rights reserved.