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,
GeneratorDialect dialect,
JpaProvider provider,
boolean relativeIds)
Creates a new instance of
SequenceIdGenerator. |
| Modifier and Type | Method and Description |
|---|---|
void |
addNextValue(InsertStatement statement,
String column,
Number value)
Adds the generated value to the given statement.
|
List<? extends EntityStatement> |
alignNextValue()
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.
|
List<? extends EntityStatement> |
createPreInsertStatements()
Creates the statements that are needed in the output before
IdGenerator.addNextValue(InsertStatement, String, Number). |
IdGenerator |
derive(String 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() |
String |
getExpression(String tableName,
String columnName,
Number targetId,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
String |
getGeneratorTable() |
long |
getInitialValue() |
long |
getMaxAllocatedValue()
The maximum allocated value.
|
long |
getNextValue() |
String |
getPkColumnName() |
String |
getPkColumnValue() |
String |
getValueColumnName() |
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,
GeneratorDialect dialect,
JpaProvider provider,
boolean relativeIds)
SequenceIdGenerator.generator - the annotation that contains our settingsdialect - the dialect of the databaseprovider - the provider of the target JPA frameworkrelativeIds - indicates that the database is not emptypublic void addNextValue(InsertStatement statement, String column, Number value)
IdGeneratoraddNextValue in class IdGeneratorstatement - the current insert statementcolumn - the name of the ID columnvalue - the current value of the column, previously generated with IdGenerator.createNextValue()public List<? extends EntityStatement> alignNextValue()
IdGeneratorcurrentValue + 1.alignNextValue in class IdGeneratorpublic long createNextValue()
IdGeneratorcreateNextValue in class IdGeneratorpublic List<? extends EntityStatement> createPreInsertStatements()
IdGeneratorIdGenerator.addNextValue(InsertStatement, String, Number).createPreInsertStatements in class IdGeneratorpublic IdGenerator derive(String currentTable)
IdGeneratorderive in class IdGeneratorcurrentTable - the name of the current entity tablepublic long getCurrentValue()
IdGeneratorIdGenerator.createNextValue(Class).getCurrentValue in class IdGeneratorpublic String getExpression(String tableName, String columnName, Number targetId, boolean whereExpression)
IdGeneratorgetExpression in class IdGeneratortableName - the name of the table of the entitycolumnName - 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 String getGeneratorTable()
@Generated(value="lombok") public String getPkColumnName()
@Generated(value="lombok") public String getPkColumnValue()
@Generated(value="lombok") public String getValueColumnName()
@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 © 2017 fastnate.org. All rights reserved.