public class TableIdGenerator extends IdGenerator
TableGenerator.| 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.
|
long |
getCurrentValue()
The last value returned by
IdGenerator.createNextValue(Class). |
String |
getExpression(String tableName,
String columnName,
Number targetId,
boolean whereExpression)
Builds the reference to another entity that has the given ID.
|
boolean |
isPostIncrement()
Indicates that
IdGenerator.createNextValue(Class) should be called after the entity was written - as the value is
not available before. |
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 executionCopyright © 2016 fastnate.org. All rights reserved.