Class MsSqlDialect

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

public class MsSqlDialect extends GeneratorDialect
Handles MS SQL specific conversions.
Author:
Tobias Liefke
See Also:
  • Constructor Details

    • MsSqlDialect

      public MsSqlDialect()
  • 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
    • 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

      protected String convertTemporalValue(Date value)
      Description copied from class: GeneratorDialect
      Builds the SQL expression for a date / time / timestamp.
      Overrides:
      convertTemporalValue in class GeneratorDialect
      Parameters:
      value - the date, already converted to one from javax.sql.*
      Returns:
      the SQL expression representing the value.
    • 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.
    • 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
    • getConcatOperator

      public String getConcatOperator()
      Description copied from class: GeneratorDialect
      The operator used to concat two Strings.
      Overrides:
      getConcatOperator in class GeneratorDialect
      Returns:
      the operator to use for "string1 OPERATOR string2" (including any necessary whitespace) or null if this dialect does not have such an operator
    • isEmulatingSequences

      public boolean isEmulatingSequences()
      Description copied from class: GeneratorDialect
      Indicates that tables are used in place of sequences, if GenerationType.SEQUENCE is defined for a GeneratedValue.
      Overrides:
      isEmulatingSequences in class GeneratorDialect
      Returns:
      true if sequences are emulated with tables, false if sequences are supported
    • isSettingIdentityAllowed

      public boolean isSettingIdentityAllowed()
      Description copied from class: GeneratorDialect
      Indicates if this dialect supports writing absolute values to an GenerationType.IDENTITY column.
      Overrides:
      isSettingIdentityAllowed in class GeneratorDialect
      Returns:
      true if we can write fix values for identity columns
    • quoteIdentifier

      public String quoteIdentifier(String name)
      Description copied from class: GeneratorDialect
      Quotes an object name for the current database dialect.
      Overrides:
      quoteIdentifier in class GeneratorDialect
      Parameters:
      name - the plain object name
      Returns:
      the quoted object name