public class TableIdGenerator extends IdGenerator
TableGenerator.
The content of the value column is interpreted like nextValue of a sequence, which means the maximum allocated
value is allways at most value column value - allocationSize.| Constructor and Description |
|---|
TableIdGenerator(javax.persistence.TableGenerator generator,
GeneratorContext context)
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). |
IdGenerator |
derive(GeneratorTable currentTable)
Some implementations (like the Hibernate table generator) create a different generator, depending on the table
name.
|
int |
getAllocationSize() |
long |
getCurrentValue()
The last value returned by
IdGenerator.createNextValue(Class). |
GeneratorDialect |
getDialect() |
ColumnExpression |
getExpression(GeneratorTable table,
GeneratorColumn column,
Number targetId,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
GeneratorTable |
getGeneratorTable() |
long |
getInitialValue() |
long |
getMaxAllocatedValue()
The maximum allocated value.
|
long |
getNextValue() |
GeneratorColumn |
getPkColumn() |
ColumnExpression |
getPkColumnValue() |
GeneratorColumn |
getValueColumn() |
boolean |
isPostIncrement()
Indicates that
IdGenerator.createNextValue(Class) should be called after the entity was written - as the value is
not available before. |
boolean |
isRelativeIds() |
void |
setCurrentValue(long currentValue)
Sets a new start value.
|
createNextValuepublic TableIdGenerator(javax.persistence.TableGenerator generator,
GeneratorContext context)
SequenceIdGenerator.generator - the annotation that contains our settingscontext - the current contextpublic 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 IdGenerator derive(GeneratorTable currentTable)
IdGeneratorderive in class IdGeneratorcurrentTable - the current entity tablepublic long getCurrentValue()
IdGeneratorIdGenerator.createNextValue(Class).getCurrentValue in class IdGeneratorpublic ColumnExpression getExpression(GeneratorTable table, GeneratorColumn column, Number targetId, boolean whereExpression)
IdGeneratorgetExpression in class IdGeneratortable - 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 boolean isRelativeIds()
@Generated(value="lombok") public GeneratorTable getGeneratorTable()
@Generated(value="lombok") public GeneratorColumn getPkColumn()
@Generated(value="lombok") public ColumnExpression getPkColumnValue()
@Generated(value="lombok") public GeneratorColumn getValueColumn()
@Generated(value="lombok") public int getAllocationSize()
@Generated(value="lombok") public long getInitialValue()
@Generated(value="lombok") public long getNextValue()
@Generated(value="lombok") public long getMaxAllocatedValue()
allocationSize greater.Copyright © 2020 fastnate.org. All rights reserved.