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. |
createNextValue
public 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)
IdGenerator
addNextValue
in class IdGenerator
statement
- 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()
IdGenerator
currentValue + 1
.alignNextValue
in class IdGenerator
public long createNextValue()
IdGenerator
createNextValue
in class IdGenerator
public List<? extends EntityStatement> createPreInsertStatements()
IdGenerator
IdGenerator.addNextValue(InsertStatement, String, Number)
.createPreInsertStatements
in class IdGenerator
public IdGenerator derive(String currentTable)
IdGenerator
derive
in class IdGenerator
currentTable
- the name of the current entity tablepublic long getCurrentValue()
IdGenerator
IdGenerator.createNextValue(Class)
.getCurrentValue
in class IdGenerator
public String getExpression(String tableName, String columnName, Number targetId, boolean whereExpression)
IdGenerator
getExpression
in class IdGenerator
tableName
- 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()
IdGenerator
IdGenerator.createNextValue(Class)
should be called after the entity was written - as the value is
not available before.isPostIncrement
in class IdGenerator
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.