Class OracleDialect

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

public class OracleDialect extends GeneratorDialect
Handles Oracle specific conversions.
Author:
Tobias Liefke
See Also:
  • Field Details

  • Constructor Details

    • OracleDialect

      public OracleDialect()
  • Method Details

    • adjustNextSequenceValue

      public void adjustNextSequenceValue(StatementsWriter writer, String sequenceName, long currentSequenceValue, long nextSequenceValue, int incrementSize) throws IOException
      Description copied from class: GeneratorDialect
      Adjusts the given sequence to ensure that the next value is exactly the given value.
      Overrides:
      adjustNextSequenceValue in class GeneratorDialect
      Parameters:
      writer - the target of the generated statements
      sequenceName - the fully qualified name of the sequence
      currentSequenceValue - the current value of the sequence
      nextSequenceValue - the next value of the sequence
      incrementSize - the increment size of the sequence
      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
    • buildNextSequenceValue

      public String buildNextSequenceValue(String sequence, int incrementSize)
      Description copied from class: GeneratorDialect
      Builds the SQL expression resp. statement that is used for creating the next value of the given sequence. Depending on GeneratorDialect.isNextSequenceValueInInsertSupported() this will return an expression or a statement.
      Overrides:
      buildNextSequenceValue 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
      Returns:
      the SQL to use in resp. before the insert / update statement
    • convertTemporalValue

      public String convertTemporalValue(Date value, jakarta.persistence.TemporalType type)
      Description copied from class: GeneratorDialect
      Converts a date to an appropriate SQL expression.
      Overrides:
      convertTemporalValue in class GeneratorDialect
      Parameters:
      value - the timestamp value
      type - the type
      Returns:
      SQL expression representing 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
    • getOptionalTable

      public String getOptionalTable()
      Description copied from class: GeneratorDialect
      Returns the string to use when no table is required, e.g. for "SELECT 1, 2 FROM DUAL" this would return "FROM DUAL".
      Overrides:
      getOptionalTable in class GeneratorDialect
      Returns:
      the SQL to use in "SELECT x [OPTIONALTABLE] WHERE ..."
    • isEmptyStringEqualToNull

      public boolean isEmptyStringEqualToNull()
      Description copied from class: GeneratorDialect
      Indicates that the empty string is equal to null in this database. Important for NotNull constraints, where an empty string would result in the same constraint violation.
      Overrides:
      isEmptyStringEqualToNull in class GeneratorDialect
      Returns:
      true if this database assumes that an empty string is the same as null
    • isFastInTransaction

      public boolean isFastInTransaction()
      Description copied from class: GeneratorDialect
      Indicates that the database usually faster when all statements are executed within an transaction. For example Oracle is approx. 25% faster but H2 is 200% slower compared to auto commit. Only relevant if executed against a running database.
      Overrides:
      isFastInTransaction in class GeneratorDialect
      Returns:
      true if an transaction is faster than auto commit
    • isIdentitySupported

      public boolean isIdentitySupported()
      Description copied from class: GeneratorDialect
      Indicates that identity columns are supported by the database.
      Overrides:
      isIdentitySupported in class GeneratorDialect
      Returns:
      true if the database supports identities
    • isSequenceInWhereSupported

      public boolean isSequenceInWhereSupported()
      Description copied from class: GeneratorDialect
      Indicates that references to sequences in WHERE expressions are supported.
      Overrides:
      isSequenceInWhereSupported in class GeneratorDialect
      Returns:
      true if this database supports sequences in WHERE expressions
    • quoteString

      public String quoteString(String value)
      Description copied from class: GeneratorDialect
      Quotes the given string.
      Overrides:
      quoteString in class GeneratorDialect
      Parameters:
      value - the value to quote
      Returns:
      the quoted string