Class PostgresDialect

java.lang.Object
org.fastnate.generator.dialect.GeneratorDialect
org.fastnate.generator.dialect.PostgresDialect

public class PostgresDialect extends GeneratorDialect
Handles PostgreSQL specific conversions.
See Also:
  • Constructor Details

    • PostgresDialect

      public PostgresDialect()
  • Method Details

    • addQuotedCharacter

      protected void addQuotedCharacter(StringBuilder result, char c)
      Description copied from class: GeneratorDialect
      Adds a quoted character to the result string buffer.
      Overrides:
      addQuotedCharacter in class GeneratorDialect
      Parameters:
      result - the current result buffer
      c - the character to quote
    • adjustNextIdentityValue

      public void adjustNextIdentityValue(StatementsWriter writer, GeneratorTable table, GeneratorColumn columnName, long nextValue) throws IOException
      Description copied from class: GeneratorDialect
      Adjusts the next value of the given identity column to ensure that it is bigger than the last generated value.
      Overrides:
      adjustNextIdentityValue in class GeneratorDialect
      Parameters:
      writer - the target of any generated statement
      table - the table of the column
      columnName - the (auto increment) identity column
      nextValue - the next value of the identity column
      Throws:
      IOException - if the writer throws one
    • buildCurrentSequenceValue

      public String buildCurrentSequenceValue(String sequence, int incrementSize, boolean firstCall)
      Description copied from class: GeneratorDialect
      Builds the SQL expression that is used for referencing the current value of the given sequence.
      Overrides:
      buildCurrentSequenceValue in class GeneratorDialect
      Parameters:
      sequence - the fully qualified name of the sequence
      incrementSize - the expected incrementSize, as given in the schema - used by some dialects to ensure that exactly that inrement is used
      firstCall - indicates that the sequence was not updated before in this session - we may need to use a different approach to get the current value
      Returns:
      the SQL expression to use in statement
    • convertBooleanValue

      public String convertBooleanValue(boolean value)
      Description copied from class: GeneratorDialect
      Converts a boolean value to an SQL expression for the current database type.
      Overrides:
      convertBooleanValue in class GeneratorDialect
      Parameters:
      value - the value to convert
      Returns:
      the SQL representation of the value
    • createAddDateExpression

      protected String createAddDateExpression(String referenceDate, long value, String unit)
      Description copied from class: GeneratorDialect
      Creates an SQL expression to add a value to a date.
      Overrides:
      createAddDateExpression in class GeneratorDialect
      Parameters:
      referenceDate - the expression for the reference date
      value - the value to add to the date
      unit - the unit of the value
      Returns:
      the SQL expression that adds the value
    • createBlobExpression

      public String createBlobExpression(byte[] blob)
      Description copied from class: GeneratorDialect
      Converts the given byte array to an SQL expression for the current database.
      Overrides:
      createBlobExpression in class GeneratorDialect
      Parameters:
      blob - the bytes to convert
      Returns:
      the expression for the bytes
    • truncateTable

      public void truncateTable(StatementsWriter writer, GeneratorTable table) throws IOException
      Description copied from class: GeneratorDialect
      Adds a "truncate table" statement to the given writer.
      Overrides:
      truncateTable in class GeneratorDialect
      Parameters:
      writer - the target of the statement
      table - the table to truncate
      Throws:
      IOException - if the writer throws one