public abstract class IdGenerator extends Object
GeneratedIdProperty
.Constructor and Description |
---|
IdGenerator() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addNextValue(InsertStatement statement,
String column,
Number nextValue)
Adds the generated value to the given statement.
|
abstract List<? extends EntityStatement> |
alignNextValue()
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.
|
abstract List<? extends EntityStatement> |
createPreInsertStatements()
Creates the statements that are needed in the output before
addNextValue(InsertStatement, String, Number) . |
IdGenerator |
derive(String table)
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 String |
getExpression(String table,
String 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. |
public abstract void addNextValue(InsertStatement statement, String column, Number nextValue)
statement
- the current insert statementcolumn
- the name of the ID columnnextValue
- the current value of the column, previously generated with createNextValue()
public abstract List<? extends EntityStatement> alignNextValue()
currentValue + 1
.protected abstract long createNextValue()
public <N extends Number> N createNextValue(Class<N> propertyClass)
propertyClass
- the type of the generated valuepublic abstract List<? extends EntityStatement> createPreInsertStatements()
addNextValue(InsertStatement, String, Number)
.public IdGenerator derive(String table)
table
- the name of the current entity tablepublic abstract long getCurrentValue()
createNextValue(Class)
.public abstract String getExpression(String table, String column, Number id, boolean whereExpression)
table
- the name of the 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 executionCopyright © 2016 fastnate.org. All rights reserved.