public class SequenceIdGenerator extends IdGenerator
SequenceGenerator
.Constructor and Description |
---|
SequenceIdGenerator(javax.persistence.SequenceGenerator generator,
GeneratorDialect dialect,
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) . |
long |
getCurrentValue()
The last value returned by
IdGenerator.createNextValue(Class) . |
String |
getExpression(String table,
String column,
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, derive
public SequenceIdGenerator(javax.persistence.SequenceGenerator generator, GeneratorDialect dialect, boolean relativeIds)
SequenceIdGenerator
.generator
- the annotation that contains our settingsdialect
- the current database dialectrelativeIds
- indicates that the sequence is always used, instead of absolute IDspublic 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 long getCurrentValue()
IdGenerator
IdGenerator.createNextValue(Class)
.getCurrentValue
in class IdGenerator
public String getExpression(String table, String column, Number targetId, boolean whereExpression)
IdGenerator
getExpression
in class IdGenerator
table
- the name of the 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()
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.