Class IdentityValue

java.lang.Object
org.fastnate.generator.context.IdGenerator
org.fastnate.generator.context.IdentityValue

public class IdentityValue extends IdGenerator
Contains the current value for a primary key of type GenerationType.IDENTITY.
Author:
Tobias Liefke
  • Constructor Details

  • Method Details

    • addNextValue

      public void addNextValue(TableStatement statement, GeneratorColumn tableColumn, Number value)
      Description copied from class: IdGenerator
      Adds the generated value to the given statement. Depending on the generator this may add the value itself or a reference to the value.
      Specified by:
      addNextValue in class IdGenerator
      Parameters:
      statement - the current insert statement
      tableColumn - the ID column of the current table
      value - the current value of the column, previously generated with IdGenerator.createNextValue()
    • alignNextValue

      public void alignNextValue(StatementsWriter writer) throws IOException
      Description copied from class: IdGenerator
      Creates all statements that are necessary to set the next value created from the database is currentValue + 1.
      Specified by:
      alignNextValue in class IdGenerator
      Parameters:
      writer - the target of the created statements
      Throws:
      IOException - if the writer throws one
    • createNextValue

      public long createNextValue()
      Description copied from class: IdGenerator
      Resolves the next value of this generator.
      Specified by:
      createNextValue in class IdGenerator
      Returns:
      the generated value
    • getExpression

      public ColumnExpression getExpression(GeneratorTable entityTable, GeneratorColumn targetColumn, Number targetId, boolean whereExpression)
      Description copied from class: IdGenerator
      Builds the reference to another entity that has the given ID.
      Specified by:
      getExpression in class IdGenerator
      Parameters:
      entityTable - the main table of the entity
      targetColumn - the name of the column of the ID
      targetId - the current value of the ID
      whereExpression - indicates if this expression is needed for a "SELECT ... WHERE ..." - some dialects behave differently in this situation
      Returns:
      the expression for selecting the ID
    • isPostIncrement

      public boolean isPostIncrement()
      Description copied from class: IdGenerator
      Indicates that IdGenerator.createNextValue(Class) should be called after the entity was written - as the value is not available before.
      Specified by:
      isPostIncrement in class IdGenerator
      Returns:
      true if the database increments the value _after_ the insert statement was executed, true if it is incremented before or during the execution
    • setCurrentValue

      public void setCurrentValue(long currentValue)
      Description copied from class: IdGenerator
      Sets a new start value.
      Specified by:
      setCurrentValue in class IdGenerator
      Parameters:
      currentValue - the current value - most likely as extracted from the target database
    • getCurrentValue

      public long getCurrentValue()
      Description copied from class: IdGenerator
      The last value returned by IdGenerator.createNextValue(Class).
      Specified by:
      getCurrentValue in class IdGenerator
      Returns:
      the current value