Class SpannerSequenceSupport

java.lang.Object
org.hibernate.dialect.sequence.SpannerSequenceSupport
All Implemented Interfaces:
SequenceSupport

public class SpannerSequenceSupport extends Object implements SequenceSupport
Sequence support for Spanner.
  • Constructor Details

    • SpannerSequenceSupport

      public SpannerSequenceSupport(SpannerDialect dialect)
  • Method Details

    • getCreateSequenceString

      public String getCreateSequenceString(String sequenceName) throws MappingException
      Description copied from interface: SequenceSupport
      Typically, dialects which support sequences can create a sequence with a single command. This method is a convenience making it easier to implement SequenceSupport.getCreateSequenceStrings(String,int,int) for these dialects.

      The default definition is to return create sequence sequenceName for the argument sequenceName. Dialects need to override this method if a sequence created in this manner does not start at 1, or if the syntax is nonstandard.

      Dialects which support sequences and can create a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to create a sequence should override SequenceSupport.getCreateSequenceStrings(String,int,int) instead.

      Specified by:
      getCreateSequenceString in interface SequenceSupport
      Parameters:
      sequenceName - The name of the sequence
      Returns:
      The sequence creation command
      Throws:
      MappingException - If sequences are not supported.
    • getCreateSequenceString

      public String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException
      Description copied from interface: SequenceSupport
      Typically, dialects which support sequences can create a sequence with a single command. This method is a convenience making it easier to implement SequenceSupport.getCreateSequenceStrings(String,int,int) for these dialects.

      Overloaded form of SequenceSupport.getCreateSequenceString(String), additionally taking the initial value and increment size to be applied to the sequence definition.

      The default definition is to suffix SequenceSupport.getCreateSequenceString(String) with the string: start with initialValue increment by incrementSize for the arguments initialValue and incrementSize. Dialects need to override this method if different key phrases are used to apply the allocation information.
      Specified by:
      getCreateSequenceString in interface SequenceSupport
      Parameters:
      sequenceName - The name of the sequence
      initialValue - The initial value to apply to 'create sequence' statement
      incrementSize - The increment value to apply to 'create sequence' statement
      Returns:
      The sequence creation command
      Throws:
      MappingException - If sequences are not supported.
    • getCreateSequenceStrings

      public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize, String options) throws MappingException
      Description copied from interface: SequenceSupport
      An optional multi-line form for databases which SequenceSupport.supportsPooledSequences().
      Specified by:
      getCreateSequenceStrings in interface SequenceSupport
      Parameters:
      sequenceName - The name of the sequence
      initialValue - The initial value to apply to 'create sequence' statement
      incrementSize - The increment value to apply to 'create sequence' statement
      options - A SQL fragment appended to the generated DDL.
      Returns:
      The sequence creation commands
      Throws:
      MappingException - If sequences are not supported.
    • getCreateSequenceString

      protected String getCreateSequenceString(String sequenceName, int initialValue, String additionalOptions)
    • getDropSequenceString

      public String getDropSequenceString(String sequenceName)
      Description copied from interface: SequenceSupport
      Typically, dialects which support sequences can drop a sequence with a single command. This is a convenience form of SequenceSupport.getDropSequenceStrings(String) which facilitates that.

      Dialects which support sequences and can drop a sequence in a single command need *only* override this method. Dialects which support sequences but require multiple commands to drop a sequence should instead override SequenceSupport.getDropSequenceStrings(String).

      Specified by:
      getDropSequenceString in interface SequenceSupport
      Parameters:
      sequenceName - The name of the sequence
      Returns:
      The sequence drop commands
    • getRestartSequenceString

      public String getRestartSequenceString(String sequenceName, long startWith)
      Description copied from interface: SequenceSupport
      A DDL statement to restart a sequence with a given value.
      Specified by:
      getRestartSequenceString in interface SequenceSupport
      Parameters:
      sequenceName - The name of the sequence
      startWith - The value to restart at
      Returns:
      The alter sequence ... restart command
    • getSequenceNextValString

      public String getSequenceNextValString(String sequenceName)
      Description copied from interface: SequenceSupport
      Generate the appropriate select statement to to retrieve the next value of a sequence.

      This should be a stand alone select statement.

      Specified by:
      getSequenceNextValString in interface SequenceSupport
      Parameters:
      sequenceName - the name of the sequence
      Returns:
      String The select "next value" statement.
    • getSelectSequenceNextValString

      public String getSelectSequenceNextValString(String sequenceName)
      Description copied from interface: SequenceSupport
      Generate the select expression fragment that will retrieve the next value of a sequence as part of another (typically DML) statement.

      This differs from SequenceSupport.getSequenceNextValString(String) in that it must return an expression usable within another statement.

      Specified by:
      getSelectSequenceNextValString in interface SequenceSupport
      Parameters:
      sequenceName - the name of the sequence
      Returns:
      The "next value" fragment.
    • supportsPooledSequences

      public boolean supportsPooledSequences()
      Description copied from interface: SequenceSupport
      Does this dialect support "pooled" sequences. Not aware of a better name for this. Essentially can we specify the initial and increment values?
      Specified by:
      supportsPooledSequences in interface SequenceSupport
      Returns:
      True if such "pooled" sequences are supported; false otherwise.
      See Also: