Package org.fastnate.generator.context
Class IdentityValue
java.lang.Object
org.fastnate.generator.context.IdGenerator
org.fastnate.generator.context.IdentityValue
Contains the current value for a primary key of type
GenerationType.IDENTITY.- Author:
- Tobias Liefke
-
Constructor Summary
ConstructorsConstructorDescriptionIdentityValue(GeneratorContext context, GeneratorTable table, GeneratorColumn column) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNextValue(TableStatement statement, GeneratorColumn tableColumn, Number value) Adds the generated value to the given statement.voidalignNextValue(StatementsWriter writer) Creates all statements that are necessary to set the next value created from the database iscurrentValue + 1.longResolves the next value of this generator.longThe last value returned byIdGenerator.createNextValue(Class).getExpression(GeneratorTable entityTable, GeneratorColumn targetColumn, Number targetId, boolean whereExpression) Builds the reference to another entity that has the given ID.booleanIndicates thatIdGenerator.createNextValue(Class)should be called after the entity was written - as the value is not available before.voidsetCurrentValue(long currentValue) Sets a new start value.Methods inherited from class org.fastnate.generator.context.IdGenerator
createNextValue, createPreInsertStatements, derive
-
Constructor Details
-
IdentityValue
-
-
Method Details
-
addNextValue
Description copied from class:IdGeneratorAdds the generated value to the given statement. Depending on the generator this may add the value itself or a reference to the value.- Specified by:
addNextValuein classIdGenerator- Parameters:
statement- the current insert statementtableColumn- the ID column of the current tablevalue- the current value of the column, previously generated withIdGenerator.createNextValue()
-
alignNextValue
Description copied from class:IdGeneratorCreates all statements that are necessary to set the next value created from the database iscurrentValue + 1.- Specified by:
alignNextValuein classIdGenerator- Parameters:
writer- the target of the created statements- Throws:
IOException- if the writer throws one
-
createNextValue
public long createNextValue()Description copied from class:IdGeneratorResolves the next value of this generator.- Specified by:
createNextValuein classIdGenerator- Returns:
- the generated value
-
getExpression
public ColumnExpression getExpression(GeneratorTable entityTable, GeneratorColumn targetColumn, Number targetId, boolean whereExpression) Description copied from class:IdGeneratorBuilds the reference to another entity that has the given ID.- Specified by:
getExpressionin classIdGenerator- Parameters:
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 situation- Returns:
- the expression for selecting the ID
-
isPostIncrement
public boolean isPostIncrement()Description copied from class:IdGeneratorIndicates thatIdGenerator.createNextValue(Class)should be called after the entity was written - as the value is not available before.- Specified by:
isPostIncrementin classIdGenerator- Returns:
trueif the database increments the value _after_ the insert statement was executed,trueif it is incremented before or during the execution
-
setCurrentValue
public void setCurrentValue(long currentValue) Description copied from class:IdGeneratorSets a new start value.- Specified by:
setCurrentValuein classIdGenerator- Parameters:
currentValue- the current value - most likely as extracted from the target database
-
getCurrentValue
public long getCurrentValue()Description copied from class:IdGeneratorThe last value returned byIdGenerator.createNextValue(Class).- Specified by:
getCurrentValuein classIdGenerator- Returns:
- the current value
-